I tried this code but it failed showing me the error "unknown error" and I think in this part findall() of my code.
Any idea how to display users into combobox or how to fix my problem?
thanks
Code:
public void User()
{
try
{
DirectoryEntry entry = new DirectoryEntry("ldap://test.atb.dom");
entry.AuthenticationType = AuthenticationTypes.Secure;
DirectorySearcher desearch = new DirectorySearcher(entry);
desearch.Filter = "(&(objectClass=user))";
SearchResultCollection results = desearch.FindAll();
foreach (SearchResult srUser in results)
{
DirectoryEntry de = srUser.GetDirectoryEntry();
if (de.Username != null)
comboBox1.Items.Add(de.Username);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
thanks