This works for me:
string strLdap =
"LDAP://serverName/CN=Users,OU=Sales,DC=Company,DC=com";
DirectoryEntry objOU = new DirectoryEntry(strLdap, "userName",
"password");
DirectorySearcher objUserSearcher = new DirectorySearcher(objOU,
"(&(objectClass=user)(objCategory=person))");
SearchResultCollection objResults;
//Search for user objects
objUserSearcher.PropertiesToLoad.Add("cn");
objResults = objUserSearcher.FindAll();
DropDownList1.Items.Add("New User");
//Loop through the search results adding each one to the combo box
foreach (SearchResult objResult in objResults)
DropDownList1.Items.Add(objResult.Properties["cn"][0]);
--
Carsten Thomsen
Enterprise Development with VS .NET, UML, AND MSF
http://www.apress.com/book/bookDisplay.html?bID=105
Communities -
http://community.integratedsolutions.dk
"Chris Geier" <chris.geier at gmail.com> wrote in message
news:CC**********************************@microsof t.com...
string strLdap = "LDAP://OU=Sales,DC=Company,DC=com"
DirectoryEntry objOU = new DirectoryEntry(strLdap);
DirectorySearcher objUserSearcher = new DirectorySearcher(objOU);
SearchResultCollection objResults;
//Search for user objects
objUserSearcher.PropertiesToLoad.Add("cn");
objUserSearcher.Filter = "(objectClass=user)";
objResults = objUserSearcher.FindAll();
DropDownList1.Items.Add("New User");
//Loop through the search results adding each one to the combo box
foreach (SearchResult objResult in objResults)
DropDownList1.Items.Add(objResult.Properties["cn"][0]);
What am I doing wrong here...