list of Login names

  • Thread starter Thread starter WildRags
  • Start date Start date
W

WildRags

Hi,
Can someone throw an idea on how to get the list of
login names of a network! I use a Win2000, Dot Net
Framework for the same.

Reply is expected.
Wild Rags
 
Use either WMI or ADSI

Watch out for Line Wraps

WMI Sample(C#.Net)
---

void DisplayUsers()
{
ManagementClass mc = new
ManagementClass("Win32_UserAccount");
ManagementObjectCollection moc =
mc.GetInstances();
foreach(ManagementObject mo in moc)
{
try
{
Console.WriteLine
("");
Console.WriteLine
("------------------------------------");
if (mo.Properties
["Domain"].Value.ToString().ToUpper()=="SSBATHENA")
{

Console.WriteLine("");
}
Console.WriteLine
(mo.Properties["Domain"].Value );
Console.WriteLine
(mo.Properties["Name"].Value );
Console.WriteLine
(mo.Properties["FullName"].Value );
Console.WriteLine
(mo.Properties["Status"].Value );
Console.WriteLine
("------------------------------------");
Console.WriteLine
("");
}
catch(Exception
p_objException)
{
Console.WriteLine
(p_objException.Message);
}
}
}


ADSI(VB.Net)
----
sub PullAllUsers(strDomain)
Dim Computer
Dim User

Set Computer = GetObject("WinNT://" & strDomain)
Computer.Filter = Array("User")
For Each User in Computer
Response.Write User.Name
Next
End Sub

hth

regards,

sr
 
Back
Top