472,126 Members | 1,564 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,126 software developers and data experts.

getting user names out of AD

I'm trying to get all the user names of users out of an active directory so
they can be put into a database, but when i run the code below it gives
nothing back, if i change username to just name it gives me the full name of
the user, but not the user name... what is going wrong? thanks

Dim entry As New DirectoryEntry("LDAP://reschini")

Dim mySearcher As New DirectorySearcher(entry)

mySearcher.Filter = "(objectClass=user)"

Dim resEnt As SearchResult

For Each resEnt In mySearcher.FindAll

Try

Me.ListBox1.Items.Add(resEnt.GetDirectoryEntry.Use rname)

Catch ex As Exception

End Try

Next
Nov 20 '05 #1
1 1063
Dim entry As New DirectoryEntry "LDAP://reschini")
Dim mySearcher As New DirectorySearcher(entry)
mySearcher.PropertiesToLoad.Add("cn")
mySearcher.Filter = "(objectclass=user)"
Dim resEnt As SearchResult

For Each resEnt In mySearcher.FindAll
If Not IsNothing(resEnt.Properties("cn")) Then
Me.ListBox1.Items.Add(resEnt.Properties
("cn")(0))
End If
Next

I took out the try in order to catch the errors, but this
should work. I think the Username is used when
Authenicating users. Hope this helps
Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Thomas | last post: by
2 posts views Thread by Sabin Finateanu | last post: by
1 post views Thread by Timothy.Rybak | last post: by
41 posts views Thread by Jim | last post: by
3 posts views Thread by =?Utf-8?B?WmlhbmdpIEpvbmVz?= | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.