My suggestion would be to also retrieve the distinguishedName of the user in
addition to their common. Given the distinguishedName, you can bind to the
user object directly.
The thing I'm not totally clear about is how to use whatever databound web
control you are using so that it does some kind of a key-value pair type of
thing. I'm sure there's an easy way to do that, but I'm not sure what that
is. However, you can cheat and just load the CN and distinguishedName into
a HashTable or StringDictionary (better yet) and use that to retrieve the
So, start with:
and go from there. Your binding string for your DirectoryEntry will be
I hope that helps.
> I am tring to the usernames in the users container to a
> drop down list. If I use Response.Write(result.Properties
> ("CN")(0) & "<Br>"), I can see the usernames, but I can't
> figure out how to bind the list to a drop down. Any help
> is appreciated!
> Dim entry As New DirectoryEntry
> ("LDAP://internal.bwater.com/CN=Users, DC=mycompany,
> DC=com", "username", "passowrd")
> Dim mySearcher As New DirectorySearcher(entry)
> Dim results As SearchResultCollection =
> Dim result As SearchResult
> For Each result In results
> ddUsers.DataSource = result.Properties("CN")
> ddUsers.DataTextField = "CN"
> Next result