Security Stuff
  • About
  • HackTheBox
    • Windows
      • Forest
      • Escape
      • Timelapse
      • Support
    • Linux
      • TwoMillion
      • Soccer
      • Pollution
      • Pilgrimage
      • Sandworm
  • Windows
    • Authentication
      • Overview
      • Logon
      • Kerberos
      • Credential
    • Active Directory
      • Domain Service
        • LDAP
        • AD Objects
      • Key Distribution Center
      • Certificate Service
    • Windows Protocols
      • SMB
    • Windows Server
      • MSSQL
    • Execution
      • Windows APIs
      • Remote Access
        • WinRM
    • Credential Access
      • Kerberos Ticket
        • Kerberoasting Attack
        • Golden/Silver Ticket Attack
        • AS-REP Roasting Attack
      • OS Credential Dumping
        • DCsync Attack
      • Certified Pre-Owned
  • Linux
    • Management
      • Package
    • Process
      • Namespace
      • Terminal
  • Web
    • Authentication
      • SAML
      • OAuth
    • Enumeration
  • Defense
    • Windows
      • Windows Event Logs
  • Development
    • Programming Language
    • Database
      • MySQL
    • Virtualization
      • Container
    • Cryptography
      • GnuPG
Powered by GitBook
On this page
  • Authentication
  • Simple Bind
  • SASL Authentication
  • Searching in AD
  • Binding
  • Name in Bind Request
  • APIs
  • ADSI
  • LDAP
  • System.DirectoryServices
  • Authorization
  • Anonymous User
  • Tools
  • ldapsearch
  • C#
  • Usage
  • Third-party Service
  • Reference
  1. Windows
  2. Active Directory
  3. Domain Service

LDAP

PreviousDomain ServiceNextAD Objects

Last updated 1 year ago

Authentication

Bind operations are used to authenticate clients to the directory server.

Active Directory supports simple, SASL and Sicily authentication mechanisms.

Simple Bind

Anonymous Authentication

The legitimate use case for this is LDAP configuration discovery.

Anonymous authentication allows anyone to fetch the root of a directory server information tree, by the Get-ADRootDSE PowerShell command for example.

rootDSE is Defined as the root of the directory data tree on a directory server and provides data about the directory server.

Unauthenticated Authentication

Many servers require that if an empty password is provided then an empty DN must also be given now.

SASL Authentication

Simple authentication and security layer. SASL can use other security layer frameworks like Kerberos for authentication.

Searching in AD

Searching in AD is a matter of

  1. finding a Domain Controller (DC),

  2. binding to the object where the search should begin in the directory,

  3. submitting a query, and

  4. processing the results.

Binding

In Active Directory Domain Services, the act of associating a programmatic object with a specific Active Directory Domain Services object is known as binding.

Name in Bind Request

Active Directory accepts several forms of name in the name field of the BindRequest.

  1. The DN of the object

  2. The user principal name (UPN) of the object.

  3. The canonical name of the object in which the rightmost forward slash (/) is replaced with a newline character (\n).

If the name field of the BindRequest maps to a single object using the attempted name form, the password on that object is checked.

APIs

The method for programmatically binding to an Active Directory object will depend on the programming technology that is used.

Programming technology
For more information

ADSI

Active Directory Service Interfaces (ADSI) is a set of COM interfaces used to access the features of directory services from different network providers.

Services can publish themselves in a directory, clients can use the directory to find the services, and both can use the directory to find and manipulate other objects of interest.

LDAP

LDAP is the only system-supplied Active Directory Service Interfaces (ADSI) provider that supports directory searching.

System.DirectoryServices

Authorization

Anonymous User

Tools

ldapsearch

Here we use ldapsearch with anonymous authentication to fetch the roo. of a directory server information tree.

$ ldapsearch -H ldap://<IP> -x -s base -b ''

C#

Build LDAP filter to look for users with SPN values registered for current domain.

$ldapFilter = "(&(objectClass=user)(objectCategory=user)(servicePrincipalName=*))"
$domain = New-Object System.DirectoryServices.DirectoryEntry
$search = New-Object System.DirectoryServices.DirectorySearcher
$search.SearchRoot = $domain
$search.PageSize = 1000
$search.Filter = $ldapFilter
$search.SearchScope = "Subtree"

$results = $search.FindAll()

$Results = foreach ($result in $results)
{
	$result_entry = $result.GetDirectoryEntry()
 
	$result_entry | Select-Object @{
		Name = "Username";  Expression = { $_.sAMAccountName }
	}, @{
		Name = "SPN"; Expression = { $_.servicePrincipalName | Select-Object -First 1 }
	}
}
 
$Results

Usage

Third-party Service

Third-party applications that integrate with AD usually use LDAP to authenticate users.

These services often store their AD credential in plain text in configuration files.

Reference

When an application binds to an object in the directory, the access privileges that the application has to that object are based on the user context specified during the bind operation. For the binding functions and methods , , GetObject, , an application can implicitly use the credentials of the caller, explicitly specify the credentials of a user account, or use an unauthenticated user context (Guest).

If fLDAPBlockAnonOps is false, anonymous users can perform any LDAP operation, subject to that use the ACL mechanisms described in this section. Refer to .

It is possible to .

A value of the attribute or

The value of the attribute + @ +

The of a in the same as the object or

A value in the attribute of the in the .

The , followed by a backslash (""), followed by the value of the sAMAccountName attribute

The of the object.

The value of the attribute

The value of the attribute

A value of the attribute

A value V that, when the MapSPN(V, M) algorithm of section is applied to it, corresponds to a value of the servicePrincipalName attribute of the object. M is the value of the attribute of the object.

The value of the attribute

A value from the attribute

Active Directory provides , the mechanisms LDAP security model does not include, in the form of access control lists (ACLs) on directory objects.

If the fLDAPBlockAnonOps heuristic of the (see section ) is true, anonymous (unauthenticated) users are limited to performing searches and binds. If fLDAPBlockAnonOps is false, anonymous users can perform any LDAP operation, subject to that use the ACL mechanisms.

ADsGetObject
ADsOpenObject
IADsOpenDSObject::OpenDSObject
Microsoft Learn - AD Schema
RFC 4513 - Anonymous Authentication
Microsoft Learn - Get-ADRootDSE
Devolutions - Why Active Directory LDAP Unauthenticated Binds Should Be Disabled, and How to Disable It
disable LDAP unauthenticated binds starting from Windows server 2019
CVE - Related vulnerability
RFC 4513 - Unauthenticated Authentication
Lithnet - Disabling Unauthenticated Binds in Active Directory
userPrincipalName
sAMAccountName
DNS name
domain
forest
uPNSuffixes
Partitions container
config NC
replica
NetBIOS domain name
canonical name
objectGUID
displayName
servicePrincipalName
[MS-DRSR]
4.1.4.2.19
sPNMappings
nTDSService
objectSid
sIDHistory
Microsoft Learn - Active Directory Service Interfaces
Netwrix - Use DirectorySearcher to get account with SPN
Microsoft Learn - DirectorySearcher Class
Netwrix - LDAP Reconnaissance
Active Directory Service Interfaces
Binding to an ADSI Object
Lightweight Directory Access Protocol
Establishing an LDAP Session
System.DirectoryServices
Binding to Directory Objects
[MS-ADTS] - Authorization
dSHeuristics
attribute
6.1.1.2.4.1.2
access checks
[MS-ADTS]: AuthenticationMicrosoftLearn
Logo
Authentication (AD DS) - Win32 appsMicrosoftLearn
[MS-ADTS]: Supported Authentication MethodsMicrosoftLearn
access checks
access control
rootDSE
Logo
Logo
[MS-ADTS]: SASL AuthenticationMicrosoftLearn
Searching in Active Directory Domain Services - Win32 appsMicrosoftLearn
Binding to Active Directory Domain Services - Win32 appsMicrosoftLearn
DirectorySearcher Class (System.DirectoryServices)MicrosoftLearn
[MS-ADTS]: AuthorizationMicrosoftLearn
Logo
Logo
Logo
Logo
Logo