Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jun 01, 2012 12:37 PM by gww
May 30, 2012 02:00 AM|LINK
Is there any simple way / code to retrieve all user name from my existing domain using vb.net?
I want to display the user name and user full name, if possible in gridview.
Any help will be highly appreciated, meanwhile I try to generate my own code.
Thanks in advance,
May 30, 2012 02:28 AM|LINK
namespace & APIs should get you started.
Jun 01, 2012 12:37 PM|LINK
Its pretty simple. All ldap queries are pretty much the same. Just need to specify what properties to load and what objects to look for. If you want to find all objects its best to start the search from the root.
Dim entry As DirectoryEntry = New DirectoryEntry(LDAPstr, LDAPuserName, LDAPpassword)
Dim obj As Object = entry.NativeObject
Dim search As DirectorySearcher = New DirectorySearcher(entry)
search.Filter = "(&(objectCategory=Person))"
Dim gresult As SearchResultCollection = search.FindAll()
Dim result As SearchResult
If (gresult Is Nothing) Then
'no users found
For Each result In gresult
'build a datatable and add each result as a new row to bind to a grid
response.write(result.Properties("name")(0).ToString & "<br>")
Catch Ex as Exception
'an error occured