All HowTo's Cyber-Security Linux Redhat, Fedora and CentOS Linux

Ldapsearch with Active Directory on Redhat/CentOS

This article demonstrates how to get data out of Active Directory using Ldapsearch.

Install the tools:

yum install openldap*

A simple grab:

ldapsearch \
    -x -h ad.server.local \
    -D "myUserName" \
    -W \
    -b "dc=company,dc=local" \
    -s sub "(cn=*)" cn mail sn

The above will get all users within LDAP hosted on the “ldap.server.local” server using the username “myUserName”. You’d be prompted for the password.

Next we grab all attributes of the account with a common name “James Brown”:

ldapsearch \
    -x -h ad.server.local \
    -D "myUserName" \
    -W \
    -b "dc=company,dc=local" "cn=James Brown"\
    -s sub "(cn=*)" cn mail sn

The above will get all information out of LDAP with the common name (real name) “James Brown”.

2 comments

Leave a Reply

Your email address will not be published. Required fields are marked *