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
| Value | Hex | Flags | What it is |
|---|---|---|---|
| -2147483646 | 0x80000002 | GROUP_TYPE_ACCOUNT_GROUP + GROUP_TYPE_SECURITY_ENABLED | Global security group. |
| -2147483644 | 0x80000004 | GROUP_TYPE_RESOURCE_GROUP + GROUP_TYPE_SECURITY_ENABLED | Domain local security group. |
| -2147483640 | 0x80000008 | GROUP_TYPE_UNIVERSAL_GROUP + GROUP_TYPE_SECURITY_ENABLED | Universal security group. |
| -2147483643 | 0x80000005 | GROUP_TYPE_BUILTIN_LOCAL_GROUP + GROUP_TYPE_RESOURCE_GROUP + GROUP_TYPE_SECURITY_ENABLED | A built-in group in the Builtin container, such as Administrators or Remote Desktop Users. |
| 2 | 0x2 | GROUP_TYPE_ACCOUNT_GROUP | Global distribution group. |
| 4 | 0x4 | GROUP_TYPE_RESOURCE_GROUP | Domain local distribution group. |
| 8 | 0x8 | GROUP_TYPE_UNIVERSAL_GROUP | Universal distribution group. |
All groupType flags
| Tick | Flag | Hex | Decimal | What it means |
|---|---|---|---|---|
0x00000001 | 1 | A group the system created in the Builtin container, such as Administrators. Only the system sets this flag. | ||
0x00000002 | 2 | Global scope: members come from the group's own domain. | ||
0x00000004 | 4 | Domain local scope: members can come from any trusted domain, and the group grants access only in its own domain. | ||
0x00000008 | 8 | Universal scope: members can come from any domain in the forest, and the group can grant access anywhere in it. | ||
0x00000010 | 16 | An application basic group of Authorization Manager. Active Directory itself does not use it. | ||
0x00000020 | 32 | An application query group of Authorization Manager. Active Directory itself does not use it. | ||
0x80000000 | 2147483648 | A 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.
| Decimal | Hex | Name | What it is |
|---|---|---|---|
0 | 0x0 | SAM_DOMAIN_OBJECT | The domain object itself. |
268435456 | 0x10000000 | SAM_GROUP_OBJECT | A global or universal security group. |
268435457 | 0x10000001 | SAM_NON_SECURITY_GROUP_OBJECT | A global or universal distribution group. |
536870912 | 0x20000000 | SAM_ALIAS_OBJECT | An alias: a domain local security group, the built-in groups included. |
536870913 | 0x20000001 | SAM_NON_SECURITY_ALIAS_OBJECT | A domain local distribution group. |
805306368 | 0x30000000 | SAM_NORMAL_USER_ACCOUNT | A user account. The same value is also named SAM_USER_OBJECT. |
805306369 | 0x30000001 | SAM_MACHINE_ACCOUNT | A computer account. |
805306370 | 0x30000002 | SAM_TRUST_ACCOUNT | The account of a trust with another domain. |
1073741824 | 0x40000000 | SAM_APP_BASIC_GROUP | An application basic group of Authorization Manager. |
1073741825 | 0x40000001 | SAM_APP_QUERY_GROUP | An 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
-
Logon failure decoder
Read failed logon events 4625, 4771 and 4776: Status and Sub Status, Kerberos failure codes and logon types.
-
LDAP error decoder
Read an LDAP error from Active Directory: result code 49 and data 52e, 775, 773 or 532.
-
userAccountControl decoder
Read 512, 514, 66048 or any other userAccountControl value flag by flag, or tick flags to build one.
-
AD rights GUID lookup
Name the GUIDs in an ACL or event 4662: extended rights, property sets, classes and attributes.
-
Kerberos encryption types decoder
Decode msDS-SupportedEncryptionTypes and ticket encryption types, and see where RC4 is still allowed.
-
Active Directory timestamp converter
Convert lastLogonTimestamp, pwdLastSet and other 18-digit values to dates and back.
-
SDDL and SID decoder
Read a security descriptor string in plain words and look up well-known SIDs.
-
GUID and SID converter
Turn an objectGUID or objectSid from base64, bytes or an immutableId into its GUID or S-1-5-21 form and back.
-
LDAP filter builder and explainer
Read an LDAP filter in plain words, with the bitwise and nested-group rules, or build one for common searches.