Active Directory Problems...



Can someone please tell me why the following doesn't return any results! I
don't get an error but at the same time I don't recieve any results from the

Would be really grateful for any advice!


Sub SetupSession()
Dim strUserName As String
Dim strADPath As String

strUserName = "netadmin" 'HttpContext.Current.User.Identity.Name
strADPath = ""

Dim Entry As DirectoryEntry = New DirectoryEntry("LDAP://" &
strADPath, "username", "xxxxxxxx")
' Create a DirectorySearcher object.
Dim mySearcher As New DirectorySearcher(entry)
' Use the FindOne method to find the object, which in this case, is
the user
' indicated by User Name and assign it to a SearchResult.
Dim ResEnt As SearchResult = mySearcher.FindOne()
' Assign a property name to propKey.
Dim propKey As String
' Assign a property name to propKey.
For Each propKey In ResEnt.Properties.PropertyNames
' Assign the property value to prop.
Dim prop As [Object]
' Assign the property value to prop.
For Each prop In ResEnt.Properties(propKey)
' Handle results. Be aware that the following WriteLine
' only returns readable results for properties that are
Console.WriteLine("{0}:{1}", propKey, prop.ToString())
Next prop
Next propKey
' Add error handling.

End Sub
End Class


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question