Re: Querying AD Groups

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"bxr222" <bxr222@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3532DD5C-20EC-435D-BB57-1FB4BF07DF66@xxxxxxxxxxxxxxxx
I ran into a problem today when querying AD Groups via WSH using either the
LDAP or WinNT provider. When I query Global Groups for their memberships I
am
only returned users and not the nested Global Groups. When I query Domain
Local Groups I get both users and Global Groups as output. We are on a
Windows 2000 domain. Anyone have any ideas? Thanks in advance.

The WinNT provider never exposes nested groups, except in local groups. The
LDAP provider exposes groups as members of groups, but you must chase the
nesting. This is true if you use the memberOf attribute of the user or the
member attribute of the group. In both cases LDAP does not expose membership
in the "Primary" group.

The tokenGroups attribute of user objects is a multi-valued collection of
the Sids of groups the user belongs to. It includes the "primary" group and
all nested groups (except in other domains). It requires some code to
retrieve group names. Also, it doesn't help enumerate the membership of a
group.

A sample VBScript program to document group membership with a recursive
subroutine to chase the member attributes of the groups is linked here:

http://www.rlmueller.net/List%20Members%20of%20a%20Group.htm

The program also uses the primaryGroupToken attribute to reveal "primary"
group membership. The program uses a dictionary object to reveal duplicates
(a user is a member directly, and then again due to membership in a nested
group) and also to prevent an infinite loop if the nesting is circular.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net


.



Relevant Pages

  • Re: User account access after account disable?
    ... thanks Joe ... So does that mean the ONLY way to validate group membership is via ldap calls? ... >> or does disabling also prevent other ...
    (microsoft.public.windows.server.active_directory)
  • Re: User account access after account disable?
    ... LDAP calls are not the only way to check group membership and are in fact ... This is how Windows does it and no LDAP is involved at all. ... You just can't log in with the account if it is ... >>> or does disabling also prevent other ...
    (microsoft.public.windows.server.active_directory)
  • Re: nested group not getting mapped drive
    ... group membership is not straightforward, even with LDAP. ... The logon script I ... The WinNT provider is blind to the hierarchy of AD, ...
    (microsoft.public.windows.server.scripting)
  • Re: LDAP returns wrong members
    ... users who are  members of the group via primary group membership. ... to get the user's full security membership via LDAP by reading the ... Co-author of "The .NET Developer's Guide to Directory Services Programming"http://www.directoryprogramming.net ...
    (microsoft.public.windows.server.active_directory)
  • Re: Does IsInRole() grab just Groups? Can I get Organizational Units?
    ... you must do an LDAP query to get OU information. ... Making security decisions based on a user's OU isn't ... >> assuming IsInRole() will not test for OU membership? ...
    (microsoft.public.dotnet.framework.aspnet.security)