Re: Querying AD for Group information (type/scope)



Or,
If you're into the new and improve way of doing things and want to use
Powershell (www.microsoft.com/powershell ) and you install the FREE Quest
ADcmdlets ( http://www.quest.com/activeroles-server/arms.aspx ), you can do
this:

1. To Query for Distribution groups:
c:\> get-qadGroup -groupType 'Distribution' | Format-Table Name,
DN -autosize
2. To query for all security groups:
c:\> get-qadGroup -groupType 'Security' | Format-Table Name,
DN -autosize
3. To query for all global security groups:
c:\> get-qadGroup -groupType 'Security' -groupScope 'global' |
Format-Table Name, DN -autosize
4. To query for all users that have some group other than "Domain Users"
designated as their "primary":
c:\> get-qadUser -LdapFilter
'(&(objectCategory=person)(objectClass=user)(!primaryGroupID=513))' |
Format-Table Name, DN -autosize

Have a go.. I think Powershell is the future and the capabilities of the
version 1 product are awesome.
For 'mere' Admins in a "Windows Environment" the impossible becomes possible
and the difficult easy.. (sorry Perl ;-) )

Regards,

Austin


"Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx> wrote in
message news:%23eVZ$YFEIHA.4880@xxxxxxxxxxxxxxxxxxxxxxx
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!






.



Relevant Pages

  • Re: Querying AD for Group information (type/scope)
    ... To query for all security groups: ... the memberOf attributes of users and the member attribute of groups ... primaryGroupID equal to 513 belong to the "Domain Users" group. ... -2147483644 Domain local security group ...
    (microsoft.public.windows.server.active_directory)
  • Re: Listing users from "Domain Users" group using AD query
    ... I want to know how to script listing of users in the "Domain Users" ... but in the 'primaryGroupID' attribute on the user ... unless someone is a member but has some other group designated as ...
    (microsoft.public.windows.server.scripting)
  • Re: Bizarre LDAP/WinNT issue
    ... Domain Users are returned, as they are when viewing Domain Users in ADUC. ... when I enumerate the member property of the Domain Users directory ... Microsoft MVP Scripting and ADSI ... primaryGroupID attribute of the user is a number that corresponds to the ...
    (microsoft.public.windows.server.active_directory)
  • RE: Hotel Booking Project Delemma
    ... you can add the DISTINCT clause in the query serving data to the report. ... > I am having a dilemma with a Hotel Booking Project which is ... > In the tblHotelBookings I have fields to capture Number of Nights, ... > If one member is booked, but has a second person ...
    (microsoft.public.access.tablesdbdesign)
  • Re: ADAM Subset
    ... Yep this would be a case for an attribute scoped query and as JoeK indicates would require a base level query, ... Joe Richards Microsoft MVP Windows Server Directory Services ... There is a trick called attribute scope query that ADAM supports that allows you to search within the values of a DN-syntax attribute (like member) to filter the results and return attributes on the objects therein. ...
    (microsoft.public.windows.server.active_directory)

Loading