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]);

Signature
Carsten Thomsen
Enterprise Development with VS .NET, UML, AND MSF
http://www.apress.com/book/bookDisplay.html?bID=105
Communities - http://community.integratedsolutions.dk
> string strLdap = "LDAP://OU=Sales,DC=Company,DC=com"
> DirectoryEntry objOU = new DirectoryEntry(strLdap);
[quoted text clipped - 10 lines]
>
> What am I doing wrong here...
CT - 30 Sep 2005 08:26 GMT
Oops, to hasty in copying and pasting; replace this line
DirectorySearcher objUserSearcher = new DirectorySearcher(objOU,
"(&(objectClass=user)(objCategory=person))");
with
DirectorySearcher objUserSearcher = new DirectorySearcher(objOU,
"(objectClass=user)");
or simply use
DirectorySearcher objUserSearcher = new DirectorySearcher(objOU);
and add the Filter you were using in your own code snippet.

Signature
Carsten Thomsen
Enterprise Development with VS .NET, UML, AND MSF
http://www.apress.com/book/bookDisplay.html?bID=105
Communities - http://community.integratedsolutions.dk
> This works for me:
>
[quoted text clipped - 27 lines]
>>
>> What am I doing wrong here...
I can get this to work perfectly in a winform. But when I want to do it from
a webform it does not work. I am getting 2 error messages focused on the last
line of code
The best overloaded method match for
'system.web.ui.webcontrols.listitemcollection.Add(string)' has some invalid
arguements
and secondly
Arguement 1 cannot convert from object to string.
John Bailo - 30 Sep 2005 18:15 GMT
It expects an object, whose value is type string.
Example:
listBoxData.Add(New ListItem("apples"))
Source:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlr
fsystemwebuiwebcontrolslistitemcollectionclassaddtopic.asp
> I can get this to work perfectly in a winform. But when I want to do it from
> a webform it does not work. I am getting 2 error messages focused on the last
[quoted text clipped - 7 lines]
>
> Arguement 1 cannot convert from object to string.