Skip to content
Tutorials Center
My learning

Topics

Lesson 17 of 38 ยท Active Directory Structure

Users, Computers and Groups in Active Directory

Learn the key Active Directory objects: user and computer accounts, important attributes (sAMAccountName, UPN, SID, userAccountControl), and group types and scopes.

Most of an Active Directory domain consists of three object kinds: users, computers and groups. Knowing their identifying attributes, how their account flags work and how groups nest is the daily vocabulary of every AD administrator, and it is what LDAP queries against AD return.

This lesson covers the naming attributes, the security identifier (SID), the userAccountControl flag word, the computer account and its machine password, and the group types and scopes (including the AGDLP pattern). Two Python stand-ins decode the bit fields for you.

User accounts

An AD user has object class chain top > person > organizationalPerson > user. Important attributes:

Attribute Meaning
cn / name The RDN value, e.g. Alice Smith
sAMAccountName Legacy logon name (asmith), up to 20 characters, unique in the domain
userPrincipalName (UPN) Modern logon name in email style, [email protected], unique in the forest
displayName, givenName, sn Name parts
mail, telephoneNumber, title, department, manager Profile data
memberOf Back-links to the groups containing the user
objectSid The security identifier
objectGUID Permanent 128-bit identifier that never changes
userAccountControl Flags: disabled, locked, password rules
pwdLastSet, lastLogonTimestamp Timestamps in 100-nanosecond intervals since 1601
whenCreated, whenChanged Creation and change times
distinguishedName Current full DN

Users can log in with either name: CORP\asmith (down-level) or [email protected] (UPN). Do not use the cn for logon: it can change independently.

SIDs

Each user, group and computer has a security identifier, such as S-1-5-21-1004336348-1177238915-682003330-1105. It consists of the revision S-1, the authority 5 (NT), the domain identifier 21-... and the relative identifier (RID) 1105. The RID is unique inside the domain; well-known ones are 500 (Administrator), 501 (Guest), 512 (Domain Admins) and 513 (Domain Users). Access control lists use SIDs, never names, so renaming an account does not change what it can access.

userAccountControl

userAccountControl is an integer where each bit is a flag. The common ones:

Hex Decimal Flag
0x0002 2 ACCOUNTDISABLE
0x0010 16 LOCKOUT
0x0020 32 PASSWD_NOTREQD
0x0200 512 NORMAL_ACCOUNT
0x1000 4096 WORKSTATION_TRUST_ACCOUNT (computer)
0x2000 8192 SERVER_TRUST_ACCOUNT (domain controller)
0x10000 65536 DONT_EXPIRE_PASSWORD
0x40000 262144 SMARTCARD_REQUIRED
0x80000 524288 TRUSTED_FOR_DELEGATION
0x400000 4194304 DONT_REQ_PREAUTH
0x800000 8388608 PASSWORD_EXPIRED

A typical enabled user has 512; the same user disabled has 514; a normal user whose password never expires has 66048 (512 + 65536). To test flags in an LDAP filter, use the bitwise AND matching rule 1.2.840.113556.1.4.803, as in LDAP Search Filters.

Account identifiers

sAMAccountName Legacy logon name.
UPN user@domain style logon.
SID Used in every ACL.
objectGUID Never changes.

Use GUID or SID for stable references

1 / 2

Computer accounts

Every domain-joined computer has an account of class computer, whose RDN ends with a dollar sign in its sAMAccountName (LAPTOP-017$). The account has its own password (the machine account password), which the computer changes automatically every 30 days by default. That password is how the computer proves itself to the domain, establishing the secure channel. Attributes you will see: dNSHostName, operatingSystem, operatingSystemVersion, lastLogonTimestamp and servicePrincipalName.

Stale computer accounts are an operational headache and a security risk; find them by lastLogonTimestamp and clean them up (see Administration).

Groups

A group is a collection of members: users, computers or other groups. Two things define it: type and scope.

Type:

  • Security groups can be used in access control lists and for rights assignment.
  • Distribution groups are only for email; they have no security meaning.

Scope (security groups):

Scope Can contain Can be used for permissions in Typical use
Domain local Users, groups from any domain, universal and global groups The same domain only Granting access to a resource
Global Users and global groups from the same domain Any domain in the forest Collecting people by role
Universal Users, global and universal groups from any domain Any domain in the forest Cross-domain roles; stored in the Global Catalog

The AGDLP pattern

A classic best practice: Accounts go in Global groups (by role), global groups go in Domain Local groups (by resource), and Permissions are given to the domain local group. For example, accounts asmith and bjones go into global group G-Sales; G-Sales becomes a member of domain local group DL-SalesShare-Modify; and DL-SalesShare-Modify has Modify permission on the share. When Sales staff change, you edit one group. In a single-domain forest, many teams use the simpler AGP (accounts, global groups, permissions), and universal groups mainly in multi-domain forests.

How groups are stored

A group has a member attribute (a list of DNs) and each member has a memberOf back-link, maintained by the server. The groupType integer encodes scope and type: -2147483646 is a global security group, -2147483644 a domain local security group, -2147483640 a universal security group, and positive values (2, 4, 8) are distribution groups. Large groups of more than about 5,000 members need ranged retrieval (member;range=0-1499) when read with LDAP, a detail most libraries hide.

Nesting works: if G-Sales is in DL-SalesShare, its members inherit the rights. Query nested membership with the in-chain rule (1.2.840.113556.1.4.1941). The PowerShell equivalent is Get-ADGroupMember -Recursive.

Decoding flags (Python stand-in)

This stand-in turns a userAccountControl value into readable flags, and a groupType into scope and type.

Python Decode userAccountControl

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Python Decode groupType and a SID

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Querying users, computers and groups

PowerShell:

POWERSHELL
Get-ADUser -Identity asmith -Properties mail, memberOf, userAccountControl, lastLogonTimestamp
Get-ADComputer -Filter 'OperatingSystem -like "Windows 11*"' -Properties OperatingSystem
Get-ADGroupMember -Identity "G-Sales" -Recursive | Select-Object Name, SamAccountName

LDAP filter equivalents:

TEXT
(&(objectCategory=person)(objectClass=user)(sAMAccountName=asmith))
(&(objectClass=computer)(operatingSystem=Windows 11*))
(&(objectClass=group)(cn=G-Sales))

objectCategory=person is indexed and typically faster than objectClass=user, but note that computers are also of class user (computer inherits from user), so filters for people should include objectCategory=person.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which attribute is a permanent identifier that never changes when an object is renamed or moved?

    The objectGUID is permanent. The DN, cn and logon name can all change.
  2. 2. A normal enabled account has userAccountControl 512. What value does the same account have when disabled?

    Disabled sets bit 0x2: 512 + 2 = 514.
  3. 3. In the AGDLP pattern, who receives the resource permissions?

    Accounts go into global groups, global groups into domain local groups, and permissions go to the domain local group.
  4. 4. Why are the RIDs 500 and 512 interesting?

    Well-known RIDs let you recognize privileged accounts and groups from the SID alone.

Summary

  • Users have a legacy sAMAccountName, a modern UPN, a SID and a permanent objectGUID.
  • userAccountControl is a bit field: 512 normal, 514 disabled, 66048 password never expires.
  • Computer accounts end in $ and carry their own machine password.
  • Groups have a type (security or distribution) and scope (domain local, global, universal); AGDLP organizes permissions.
  • Filter people with objectCategory=person; follow nested membership with the in-chain rule.

Next: Sites and Replication