BrianS
10-17-2007, 07:24 PM
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
{
}
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
{
}