Skip to main content

Overview

The ldaptypes module provides structures for working with Windows security descriptors, Access Control Lists (ACLs), and Security Identifiers (SIDs) in their LDAP/non-RPC binary format.

Security Identifiers

LDAP_SID

Represents a Security Identifier in LDAP format.

Methods

formatCanonical() Returns the SID in canonical string format.
fromCanonical(canonical) Parse a canonical SID string into the structure.

Security Descriptors

SR_SECURITY_DESCRIPTOR

Self-relative security descriptor as defined in MS-DTYP 2.4.6.

Structure Fields

  • Revision (byte): Descriptor revision (usually 1)
  • Control (short): Control flags
  • OwnerSid (LDAP_SID): Owner SID
  • GroupSid (LDAP_SID): Primary group SID
  • Sacl (ACL): System ACL
  • Dacl (ACL): Discretionary ACL

Example

Access Control Lists

ACL

Represents an Access Control List containing multiple ACEs.

Structure Fields

  • AclRevision (byte): ACL revision
  • AceCount (short): Number of ACEs
  • aces (list): List of ACE objects

Access Control Entries

ACE

Base ACE structure. The actual ACE type is determined by the AceType field.

ACE Flags

ACCESS_ALLOWED_ACE

Grants access rights to a trustee.

ACCESS_ALLOWED_OBJECT_ACE

Object-specific access control for Active Directory.

Object ACE Rights

ACCESS_DENIED_ACE

Denies access rights to a trustee.

ACCESS_DENIED_OBJECT_ACE

Object-specific access denial.

Access Masks

ACCESS_MASK

Represents access rights in an ACE.

Standard Rights

Methods

hasPriv(priv) Check if a specific privilege is set.
setPriv(priv) Set a specific privilege.
removePriv(priv) Remove a specific privilege.

Security Descriptor Flags

LDAP_SERVER_SD_FLAGS

Control which parts of the security descriptor to retrieve.

Flags

  • OWNER_SECURITY_INFORMATION (0x1): Owner SID
  • GROUP_SECURITY_INFORMATION (0x2): Group SID
  • DACL_SECURITY_INFORMATION (0x4): DACL
  • SACL_SECURITY_INFORMATION (0x8): SACL

Object Type GUIDs

OBJECTTYPE_GUID_MAP

Common object class GUIDs for Active Directory.

Complete Example