Active Directory Problems...

G

Guest

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
AD????

Would be really grateful for any advice!

Thanks


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

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

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
strings.
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

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top