|
-
Apr 8th, 2004, 04:00 PM
#1
Thread Starter
PowerPoster
Active Directory...How to get users in a group?
I need to get all the login names and corrisponding friendly names from active directory that are in a certain group. How would I do this?
-
Apr 9th, 2004, 10:13 AM
#2
Thread Starter
PowerPoster
Bumping this because it is pretty important for me to continue my project...
-
Apr 9th, 2004, 10:58 AM
#3
Frenzied Member
Searching MSDN came up with this , haven't tried it, though.
-
Apr 9th, 2004, 05:17 PM
#4
Thread Starter
PowerPoster
Yea, I have tried all the examples I could find. I can get a complete listing of AD users, but I can't get them from a single group right now.
-
Apr 9th, 2004, 09:42 PM
#5
Here you go, I had to convert it from some code I previously did that got all groups a user was in. I see what you mean about not finding much info on how to reverse that and get all users in a group but this should work:
VB Code:
'syntax
ListBox1.Items.AddRange(GetMembersOfGroup("edneeis.local", "Administrators"))
Private Function GetMembersOfGroup(ByVal domain As String, ByVal group As String) As String()
'set domain path
Dim de As New DirectoryEntry(String.Format("LDAP://{0}", domain))
Dim srch As New DirectorySearcher(de)
'filter find all groups with the name provided
srch.Filter = String.Format("(&(objectClass=group)(Name={0}))", group)
Dim al As New ArrayList
For Each res As SearchResult In srch.FindAll
'get all members
For Each obj As Object In res.Properties("Member")
'trim to a more legible name
al.Add(TrimToName(obj))
Next
Next
Return CType(al.ToArray(GetType(String)), String())
End Function
Private Function TrimToName(ByVal path As String) As String
Dim parts() As String = path.Split(",")
Return parts(0).Replace("CN=", String.Empty)
End Function
-
Apr 10th, 2004, 11:27 AM
#6
Thread Starter
PowerPoster
Thanks, I am not on a network until next week now, so I will have to give it a try then.
Appreciate it.
-
Apr 21st, 2005, 10:31 AM
#7
Addicted Member
Re: Active Directory...How to get users in a group?
Hey, that code is not working. You should come back and make it work
-
Apr 21st, 2005, 10:26 PM
#8
Re: Active Directory...How to get users in a group?
 Originally Posted by dani2
Hey, that code is not working. You should come back and make it work 
You may want to be more specific then that. It works when I run it. What makes you say otherwise?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|