Re: Querying AD for Group information (type/scope)
- From: "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 16 Oct 2007 19:39:45 -0500
For example, to query for all distribution groups ("|" is the NOT operator):
(&(objectCategory=group)(!groupType:1.2.840.113556.1.4.803:=2147483648))
To query for all security groups:
(&(objectCategory=group)(groupType:1.2.840.113556.1.4.803:=2147483648))
To query for all global security groups:
(&(objectCategory=group)(groupType:1.2.840.113556.1.4.803:=2))
To query for all users that have "Domain Users" designated as their
"primary" group:
(&(objectCategory=person)(objectClass=user)(primaryGroupID=513))
To query for all users that have some group other than "Domain Users"
designated as their "primary":
(&(objectCategory=person)(objectClass=user)(!primaryGroupID=513))
A VBScript function I use to determine the group type:
==================
Set objGroup = GetObject("LDAP://cn=TestGroup,ou=West,dc=MyDomain,dc=com")
Wscript.Echo "Group " & objGroup.Name & " is type " &
GetType(objGroup.groupType)
Function GetType(ByVal intType)
' Function to determine group type from the GroupType attribute.
If ((intType And &h01) <> 0) Then
GetType = "Built-in"
ElseIf ((intType And &h02) <> 0) Then
GetType = "Global"
ElseIf ((intType And &h04) <> 0) Then
GetType = "Local"
ElseIf ((intType And &h08) <> 0) Then
GetType = "Universal"
End If
If ((intType And &h80000000) <> 0) Then
GetType = GetType & "/Security"
Else
GetType = GetType & "/Distribution"
End If
End Function
================
Finally, the memberOf attributes of users and the member attribute of groups
does not include "primary" group membership. Instead, the primaryGroupID of
the user object designates the primary group. The value equals the
corresponding value of the primaryGroupToken of the "primary" group. The
group "Domain Users" has primaryGroupToken equal to 513, so all users with
primaryGroupID equal to 513 belong to the "Domain Users" group. For computer
objects the "primary" group (by default) is "Domain Computers", which has
primaryGroupToken equal to 515. The default "primary" group for DC's is
"Domain Controllers", which has primaryGroupToken equal to 516.
--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
"Austin Osuide" <austin@xxxxxxxxxxx> wrote in message
news:uBd9ImEEIHA.1164@xxxxxxxxxxxxxxxxxxxxxxx
Hi ATC,
The "type" of a group is held in the groupType attribute which you can
ascertain with a query.
Values for the different group types are:
2 Global distribution group
4 Domain local distribution group
8 Universal distribution group
-2147483646 Global security group
-2147483644 Domain local security group
-2147483640 Universal security group
The reason the member attribute of the "Domain users" and some other
System Groups is empty is because for these groups, to get round the 5k
membership limit for groups, AD does not write a forward link for the
"primaryGroupID" of the user and membership is implied.
See: http://support.microsoft.com/kb/275523
Regards,
Austin
"ATC" <ATC@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:02CBD7C4-9289-4844-848A-63DD7E856272@xxxxxxxxxxxxxxxx
Is there a way to use an LDAP query to return the type (Security vs
Distribution) and scope (Local vs Global vs Universal) of a group?
Also, are some group memberships "calculated" (not sure of correct term)
instead of stored in the "member" attribute? Because I've noticed that
some
groups like "Domain Users" and "Domain Controllers" have nothing listed
in
their "member" attribute even though they have compuers or people listed
as
members when looking at their memberships via the admin console.
Thanks!
.
- Follow-Ups:
- Re: Querying AD for Group information (type/scope)
- From: Austin Osuide
- Re: Querying AD for Group information (type/scope)
- References:
- Querying AD for Group information (type/scope)
- From: ATC
- Re: Querying AD for Group information (type/scope)
- From: Austin Osuide
- Querying AD for Group information (type/scope)
- Prev by Date: Re: Dedicated AD forest for external users?
- Next by Date: RE: Provide feedback to DC promotion/replacement
- Previous by thread: Re: Querying AD for Group information (type/scope)
- Next by thread: Re: Querying AD for Group information (type/scope)
- Index(es):
Relevant Pages
|