Home All Groups Group Topic Archive Search About
Author
16 Feb 2006 5:23 PM
Ed
Hi,
I have an LDAP query that I want to use to populate a dropdown/list box
but when debugging the box seems to have the correct amount of entry in
it but they are all: System.DirectoryServices.SearchResult. How can I
get this to work?

Code to retrieve groups beginning with Door (i.e. Door 1, Door 2, Door
3)

Dim path as String = "LDAP://OU=InfraSec, DC=itsec, DC=ac, DC=uk"
Dim searcher As DirectorySearcher = New DirectorySearcher(entry)
Search.filter() = "(cn=Door*)"

Dim result As SearchResult
For Each result In searcher.FindAll()
            DoorList.Items.Add(result.ToString)
Next

Author
16 Feb 2006 5:52 PM
Phillip Williams
When you used DoorList.Items.Add(result.ToString) you got a string
representation of the object type which is a SearchResult class

Try modifying your code like this:

'assuming you wanted to bind the list to the "Email"
searcher.PropertiesToLoad.Add("Email")
Dim result As SearchResult
For Each result In searcher.FindAll()
             DoorList.Items.Add(result.Properties("Email")(0).toString)
Next

Show quoteHide quote
"Ed" wrote:

> Hi,
> I have an LDAP query that I want to use to populate a dropdown/list box
> but when debugging the box seems to have the correct amount of entry in
> it but they are all: System.DirectoryServices.SearchResult. How can I
> get this to work?

> Code to retrieve groups beginning with Door (i.e. Door 1, Door 2, Door
> 3)

> Dim path as String = "LDAP://OU=InfraSec, DC=itsec, DC=ac, DC=uk"
> Dim searcher As DirectorySearcher = New DirectorySearcher(entry)
> Search.filter() = "(cn=Door*)"

> Dim result As SearchResult
> For Each result In searcher.FindAll()
>             DoorList.Items.Add(result.ToString)
> Next


>