Workflow Tools Control Yard

Home / Active Directory

groupType and sAMAccountType decoder

Active Directory keeps the scope and type of a group in groupType, a set of flags, and the kind of every account in sAMAccountType, a single value. Enter either number to read it.

groupType

Active Directory stores groupType as a signed 32-bit number, so every security group has a negative value: the security flag is the highest bit.

Common values

ValueHexFlagsWhat it is
-21474836460x80000002GROUP_TYPE_ACCOUNT_GROUP + GROUP_TYPE_SECURITY_ENABLEDGlobal security group.
-21474836440x80000004GROUP_TYPE_RESOURCE_GROUP + GROUP_TYPE_SECURITY_ENABLEDDomain local security group.
-21474836400x80000008GROUP_TYPE_UNIVERSAL_GROUP + GROUP_TYPE_SECURITY_ENABLEDUniversal security group.
-21474836430x80000005GROUP_TYPE_BUILTIN_LOCAL_GROUP + GROUP_TYPE_RESOURCE_GROUP + GROUP_TYPE_SECURITY_ENABLEDA built-in group in the Builtin container, such as Administrators or Remote Desktop Users.
20x2GROUP_TYPE_ACCOUNT_GROUPGlobal distribution group.
40x4GROUP_TYPE_RESOURCE_GROUPDomain local distribution group.
80x8GROUP_TYPE_UNIVERSAL_GROUPUniversal distribution group.

All groupType flags

TickFlagHexDecimalWhat it means
0x000000011A group the system created in the Builtin container, such as Administrators. Only the system sets this flag.
0x000000022Global scope: members come from the group's own domain.
0x000000044Domain local scope: members can come from any trusted domain, and the group grants access only in its own domain.
0x000000088Universal scope: members can come from any domain in the forest, and the group can grant access anywhere in it.
0x0000001016An application basic group of Authorization Manager. Active Directory itself does not use it.
0x0000002032An application query group of Authorization Manager. Active Directory itself does not use it.
0x800000002147483648A security group: its membership goes into the access token, so it can be given permissions. Without this flag the group is a distribution group.

The scope flags exclude each other: a group has exactly one of them. The security flag can be added to any of the first four.

sAMAccountType

Windows sets sAMAccountType itself when an account is created, from the kind of object and, for a group, from its groupType. The values are not flags and are never added together.

DecimalHexNameWhat it is
00x0SAM_DOMAIN_OBJECTThe domain object itself.
2684354560x10000000SAM_GROUP_OBJECTA global or universal security group.
2684354570x10000001SAM_NON_SECURITY_GROUP_OBJECTA global or universal distribution group.
5368709120x20000000SAM_ALIAS_OBJECTAn alias: a domain local security group, the built-in groups included.
5368709130x20000001SAM_NON_SECURITY_ALIAS_OBJECTA domain local distribution group.
8053063680x30000000SAM_NORMAL_USER_ACCOUNTA user account. The same value is also named SAM_USER_OBJECT.
8053063690x30000001SAM_MACHINE_ACCOUNTA computer account.
8053063700x30000002SAM_TRUST_ACCOUNTThe account of a trust with another domain.
10737418240x40000000SAM_APP_BASIC_GROUPAn application basic group of Authorization Manager.
10737418250x40000001SAM_APP_QUERY_GROUPAn application query group of Authorization Manager.

LDAP filters and PowerShell

(sAMAccountType=805306368)
(sAMAccountType=805306369)
(groupType:1.2.840.113556.1.4.803:=2147483648)
(&(objectCategory=group)(!(groupType:1.2.840.113556.1.4.803:=2147483648)))
Get-ADObject -LDAPFilter "(sAMAccountType=805306368)"
Get-ADGroup -Filter 'GroupCategory -eq "Security" -and GroupScope -eq "Global"'

The filters find all user accounts, all computer accounts, all security groups and all distribution groups. sAMAccountType is indexed, which makes it a quick way to ask for users. For the bitwise rule, Microsoft's own example writes the security flag as the unsigned number 2147483648; to match one exact value, write it the way Active Directory stores it, as in (groupType=-2147483646).

Sources

The flags, values and names are from Microsoft's documentation: the Group-Type and SAM-Account-Type attribute pages, section 2.2.12 of [MS-ADTS], the account type values of [MS-SAMR] and the Search Filter Syntax page of the ADSI documentation. Microsoft publishes the attribute pages and the ADSI documentation under the Creative Commons Attribution 4.0 International licence. The descriptions here are this site's own wording.

More Active Directory tools