469,927 Members | 1,708 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

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 1015
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
By using this site, you agree to our Privacy Policy and Terms of Use.