View Single Post
Old 10-17-2007, 07:24 PM   #1
BrianS
Canal Junkie
iTrader: (4)
 
BrianS's Avatar
 
Join Date: May 2003
Location: Raynham
Posts: 1,678
Send a message via AIM to BrianS
C# and Active Directory ***geeky programming question warning***

I have a problem in that I am looking to pull a list of users from Active Directory into my application.

I actually have it working in that I have pulled ALL "users" in, but its also bringing in users that are Inactive.

How can I designate and only pull in "active" users?

This is my code as it works now.. Any assistance would be GREATLY appreciated.


try
{
string path = "LDAP://bosdc1/CN=Users,DC=firm,DC=gsxxx,DC=com";
DirectoryEntry AD = new DirectoryEntry(path);
AD.Username = "GS\\xxxxx";
AD.Password = "xxxxx";

AD.Username = "GS\\xxxxx";
AD.Password = "xxxxx";
AD.Children.SchemaFilter.Add("user");


foreach (DirectoryEntry obj in AD.Children)
{
string replaced = FixString(obj.Name.ToString(), "CN=", "");
replaced = FixString(replaced, "\\", "");
ADUsersList.Items.Add(replaced);
}
}
catch
{
}

aim: SaltedBrian
BrianS is offline   Reply With Quote