ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local"Performs a basic anonymous query against the target IP using simple authentication.
The OpenLDAP query client. Dumps users, groups, computers and attributes from LDAP and Active Directory with precise filters.
sudo apt install ldap-utilsldapsearch -x -D "cn=admin,dc=example,dc=local" -W -H ldap://192.168.1.10 -b "dc=example,dc=local"Authenticates with a specific Bind DN and prompts the user for the password interactively.
ldapsearch -x -D "cn=admin,dc=example,dc=local" -w "P@ssw0rd123" -H ldap://192.168.1.10 -b "dc=example,dc=local"Authenticates providing the password inline (less secure, useful for scripts).
ldapsearch -x -D "EXAMPLE\Administrator" -W -H ldap://192.168.1.10 -b "dc=example,dc=local"Uses the Active Directory down-level logon name format for binding.
ldapsearch -x -D "admin@example.local" -W -H ldap://192.168.1.10 -b "dc=example,dc=local"Uses the User Principal Name (UPN) format for binding to Active Directory.
ldapsearch -x -D "cn=admin,dc=example,dc=local" -y passfile.txt -H ldap://192.168.1.10Reads the bind password from a specified file to avoid exposing it in the command history.
ldapsearch -x -H ldaps://dc.example.local:636 -b "dc=example,dc=local"Connects over SSL (LDAPS) on the standard secure port 636.
ldapsearch -x -Z -H ldap://dc.example.local -b "dc=example,dc=local"Initiates a StartTLS operation to upgrade a cleartext connection to an encrypted one.
ldapsearch -x -ZZ -H ldap://dc.example.local -b "dc=example,dc=local"Enforces StartTLS and fails the connection if the TLS upgrade is not successful.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -s baseSearches only the base object itself, useful for checking RootDSE or specific object attributes.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -s oneSearches one level deep (immediate children) excluding the base object itself.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -s subPerforms a subtree search, searching the base object and the entire hierarchy below it (default).
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(objectClass=person)" cn mailRetrieves only the Common Name and Email attributes for person objects.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(objectClass=*)" * +Retrieves all user attributes (*) and all operational attributes (+) like modifyTimestamp.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -u "(objectClass=person)"Displays the User Friendly Name (UFN) of the Distinguished Name in the output.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -A "(objectClass=person)"Retrieves attribute names only without their values, useful for schema discovery.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -LLOutputs in LDIF format without comments, suitable for processing by other tools.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -LLLOutputs in raw LDIF format without comments or version information.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -LOutputs in LDIF format v1 (standard default).
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -CAutomatically chases referrals to other LDAP servers.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -MSends the ManageDsaIT control, instructing the server to return referral objects as entries rather than chasing them.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -a alwaysAlways dereference aliases during both searching and finding.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -E pr=1000/nopromptUses the Paged Results control to retrieve datasets larger than the server's size limit (e.g., AD's 1000 limit).
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -E sss=-cnRequests Server Side Sorting of results by Common Name in descending order.
ldapsearch -H ldap://dc.example.local -Y GSSAPI -b "dc=example,dc=local"Authenticates using Kerberos (GSSAPI) via the current user's Ticket Granting Ticket.
ldapsearch -H ldap://dc.example.local -Y DIGEST-MD5 -U admin -b "dc=example,dc=local"Authenticates using the DIGEST-MD5 SASL mechanism for the user 'admin'.
ldapsearch -H ldapi:/// -Y EXTERNAL -b "cn=config"Uses Unix socket (IPC) authentication, often used for root access to local OpenLDAP configuration.
ldapsearch -H ldap://dc.example.local -Y GSSAPI -O max -b "dc=example,dc=local"Uses GSSAPI with maximum security properties (encryption and integrity protection).
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(cn=John Doe)"Filters for objects where the Common Name is exactly 'John Doe'.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(cn=J*)"Filters for objects where the Common Name starts with 'J' (wildcard).
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(description=*)"Filters for objects where the 'description' attribute is present (not null).
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(gidNumber>=1000)"Filters for objects where the gidNumber is greater than or equal to 1000.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(&(objectClass=user)(cn=admin))"Uses the AND operator to find objects that are both a user AND have the common name 'admin'.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(|(cn=admin)(cn=root))"Uses the OR operator to find objects that are named 'admin' OR 'root'.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(&(objectClass=user)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))"Uses the NOT operator and bitwise logic to find active users (excluding disabled accounts).
ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(objectClass=user)" sAMAccountNameEnumerates all user login names (sAMAccountName) in an Active Directory domain.
ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(objectClass=group)" cn memberEnumerates all groups and lists their member DNs.
ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(objectCategory=Computer)" name operatingSystemEnumerates all computer objects and their operating system versions.
ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(servicePrincipalName=*)" servicePrincipalNamePerforms 'Kerberoasting' recon by identifying accounts with Service Principal Names (SPNs).
ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(adminCount=1)" cnIdentifies high-value targets by searching for objects protected by AdminSDHolder (adminCount=1).
ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(userAccountControl:1.2.840.113556.1.4.803:=524288)" cnIdentifies accounts configured with 'Trusted for Delegation' (risky configuration).
ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(userAccountControl:1.2.840.113556.1.4.803:=4194304)" cnIdentifies accounts with 'Do not require Kerberos preauthentication' enabled (AS-REP Roasting targets).
ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(pwdLastSet=0)" cnFinds accounts that must change their password at next logon.
ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(userAccountControl:1.2.840.113556.1.4.803:=65536)" cnFinds accounts where the password is set to never expire.
ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(description=*password*)" descriptionSearches for the string 'password' inside description fields, a common place for leaked credentials.
ldapsearch -x -H ldap://192.168.1.10 -s base -b "" +Queries the RootDSE (empty base DN) for operational attributes to discover server capabilities and contexts.
ldapsearch -x -H ldap://192.168.1.10 -s base -b "cn=Subschema" attributeTypesQueries the LDAP schema to list all defined attribute types.
ldapsearch -x -H ldap://192.168.1.10 -s base -b "" namingContextsRetrieves the naming contexts to identify valid base DNs for future searches.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -vRuns in verbose mode, showing diagnostics to standard error.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -d 1Runs with debug level 1 (trace) to view detailed connection handling information.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -nPerforms a dry run, showing what would be done without actually connecting to the server.
ldapsearch -x -H ldap://192.168.1.10 -f filters.txt -b "dc=example,dc=local"Reads a series of filters from a file and performs a search for each one.
ldapsearch -x -H ldap://[fe80::1] -b "dc=example,dc=local"Connects to an LDAP server using an IPv6 address literal.
ldapsearch -x -H ldap://dc.example.local -b "CN=Policies,CN=System,DC=example,DC=local" -s sub "(objectClass=*)"Retrieves Group Policy Objects (GPO) information from the System container.
ldapsearch -x -H ldap://dc.example.local -b "DC=ForestDnsZones,DC=example,DC=local" "(objectClass=*)"Enumerates DNS records stored within the Active Directory Forest DNS Zones.
ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(ms-Mcs-AdmPwd=*)" ms-Mcs-AdmPwdAttempts to retrieve cleartext Local Administrator Password Solution (LAPS) passwords.
ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(objectClass=msExchExchangeServer)"Identifies Microsoft Exchange servers within the environment.
ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(&(objectClass=user)(!(pwdLastSet=*)))"Finds users who have never set a password (potential stale or uninitialized accounts).
ldapsearch -x -H ldap://dc.example.local -b "dc=example,dc=local" "(&(objectCategory=person)(objectClass=user)(primaryGroupID=512))"Finds users whose Primary Group ID is 512 (Domain Admins), verifying high-privilege membership.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(cn~=john)"Uses the 'approximate' (sounds like) operator to find values that sound like 'john'.
ldapsearch -x -H ldap://192.168.1.10 -b "cn=schema" -s base objectClassesDumps the full list of Object Classes defined in the schema.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -L > backup.ldifRedirects standard output to a file to create a backup in LDIF format.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -E !pr=1000/nopromptUses the 'Critical' (!) flag with paging, forcing the server to return an error if it doesn't support paging.
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" "(objectClass=*)" 1.1Requests the special attribute '1.1', which tells the server to return entries with NO attributes (DNs only).
ldapsearch -x -H ldap://192.168.1.10 -b "dc=example,dc=local" -l 0Sets the time limit to 0 (unlimited), instructing the client to wait indefinitely for the server response.
Using CrackMapExec/NetExec to enumerate SMB, LDAP, WinRM and MSSQL across a network: shares, users, sessions, policies and more.
A Python ingestor for BloodHound that collects Active Directory objects, ACLs and sessions from Linux, revealing attack paths to high-value targets.
Samba’s MS-RPC client. Queries domain users, groups, password policies and SIDs over SMB, often with a null or low-privilege session.