☰ LDAP Commands
# Command Description

LDAP Commands

1ldapwhoami -x -D "uid=dadmin,cn=users,dc=stevedunlap,dc=com" -WTest LDAP authentication with the specified user.
2ldapwhoami -x -D "cn=Directory Manager" -WTest authentication with the Directory Manager account.
3ldapwhoami -Y EXTERNAL -H ldapi:///Test external SASL authentication over the ldapi protocol.
4ldapsearch -x -LLL -b "dc=stevedunlap,dc=com" "(objectClass=inetOrgPerson)"Search for all entries of objectClass inetOrgPerson in the base DN.
5ldapsearch -x -LLL -b "cn=users,dc=stevedunlap,dc=com" "(objectClass=*)"Retrieve all entries under the 'users' container.
6ldapsearch -x -LLL -b "cn=subschema" "(objectClass=*)" objectClassesRetrieve available objectClasses in the LDAP schema.
7ldapsearch -x -LLL -b "uid=root,cn=users,dc=stevedunlap,dc=com"Search for the root user's entry in the LDAP directory.
8ldapadd -x -D "uid=dadmin,cn=users,dc=stevedunlap,dc=com" -W -f contacts.ldifImport contacts from an LDIF file into LDAP using the dadmin account.
9ldapadd -x -D "cn=Directory Manager" -W -f dadmin.ldifAdd the Directory Manager user from the specified LDIF file.
10ldapmodify -x -D "uid=dadmin,cn=users,dc=stevedunlap,dc=com" -W -f delete.ldifModify or delete LDAP entries using the specified LDIF file.
11slapcat -b "dc=stevedunlap,dc=com" -l users_backup.ldifExport all LDAP entries to an LDIF file for backup.
12slapcat -n 0 -l ldap_config_backup.ldifExport the LDAP configuration (schemas, ACLs, etc.) to an LDIF file.

Open Directory Management

13sudo slapconfig -getstyleCheck the Open Directory configuration style (master, replica, etc.).
14sudo slapconfig -destroyldapserverRemove the Open Directory server configuration and data.
15sudo slapconfig -createldapmasterandadmin dadmin "Directory Administrator" 1000Create a new Open Directory master and admin user.

System and Hostname

16hostnameShow the current system hostname.
17ping -c 1 stevedunlap.comTest if the hostname resolves correctly to an IP address.

User Management

18dscacheutil -q user -a name stephendCheck if the user exists locally on the system.
19sudo dscl . -create /Users/localadminCreate a new local admin user.

Debugging and Logs

20sudo tail -f /var/log/slapd.logMonitor the LDAP log file for debugging.