Discussion Locked

LDAP Find users within a group

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Using ADUC I tried to find which users were members of the Internet group using:
(objectCategory=user)(memberOf=CN=internet)
Removing the "CN=" still results in a "is not a valid query string" How do I find out which users are members of a particular group ??
All help appreciated,
Banx

5 replies

by faradhi

The members of a group are stored in a delimited property of the group.

Here is a VBScript that will enumerate the members of a group.

Option Explicit
Dim strMember, strDNSDomain, strContainer
Dim objGroup, objRootDSE
Dim arrMemberOf, arrCPU

' Bind to Active Directory'
strContainer = "cn=AllWorkstations,cn=Computers, " 'Change this to the group in question
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")

' Get the group
Set objGroup = GetObject ("LDAP://"& strContainer & strDNSDomain)
objGroup.getInfo

arrMemberOf = objGroup.GetEx("member") 'Loads group into an Array

' Loop = For Each .... Next
WScript.Echo "Members of Group " & strContainer
For Each strMember in arrMemberOf
arrCPU = Split(strMember,",") 'Splits the member which is listed as Distinguished name
WScript.echo Right(arrCPU(0), Len(arrCPU(0))-3) 'Takes the computer name and removes the "CN=" part.
Next

Wscript.Quit

by banx

Thanx for taking the time to reply. VBS scripting is not one of my secialities but have passed it on to a colleague to make sense of it for me. Will advise on how i get on.

:-)

by gerardo.tiscareno

I have the same problem but i want to do is a report in crystal with the same type of query, can please some one help me

by sysoevpa

It is work! Right for Crystal Report this LDAP:

SELECT name FROM 'LDAP://dc=domain,dc=com'
WHERE
objectClass = 'user' and memberOf='CN=Group,OU=Groups,DC=domain,DC=com'

This discussion is closed to new replies.