Setting Primary Group Excludes the User from the Group Membership in Active Directory


When you view Active Directory with a Lightweight Directory Access Protocol (LDAP) utility such as Ldp.exe, the Members attribute is not populated with the Primary group.

The memberof attribute of the user object is not populated with the group name. This can cause problems if programs do not query Active Directory for the PrimaryGroupID attribute, and only for the Members attribute of the group.


This behavior occurs because Microsoft Windows 2000 has a group membership limitation of 5000 users. This behavior is due to a limitation in the size of the attribute that is being replicated. The primary group allows one group per user to hold more than 5000 users. By default, every user is a member of the Domain Users group.

The Microsoft Windows Server 2003 Forest mode removes this group membership limitation. However, the primary group is still used in the same way.


To resolve this behavior, create a separate attribute called PrimaryGroupID. When you do this, all users can be a member of the Domain Users global group, but instead of explicitly adding them to the Domain Users group membership, assign the user a value for this group in the PrimaryGroupID value. The PrimaryGroupID value is the RID of the group which is assigned as the user's Primary group.

To make sure that the user has the appropriate access to resources in the domain, you not only calculate group membership based on the memberof attribute, you also query for the value of the PrimaryGroupID of the user accounts. When you do this, you create the user's Token, and include the Primary group at the log-on process for all of the groups of which the user is a member.

Programs that need to query groups to give users access that is based on group membership should also query for the PrimaryGroupID attribute.

If more than 5000 users need to be added to a group, work around the 5000 member limitation for groups by using nested groups under a master (parent) group.

More Information

The Primary Group ID (PrimaryGroupID) is an integer value that represents the primary group ID for this user.

The following example describes how to obtain the PrimaryGroupID user attribute by using Microsoft Visual Basic (VB) script:

   Set usr = GetObject("WinNT://TestDomain/JSmith")
UserID = usr.Get("PrimaryGroupID")
MsgBox "The User's Primary Group ID is:"& UserID

ID článku: 275523 - Poslední kontrola: 7. 1. 2008 - Revize: 1

Váš názor