All Linux HowTo's

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”.

Similar Posts:

One comment

  1. I see you don’t monetize your blog, don’t waste your traffic, you can earn additional bucks
    every month. You can use the best adsense alternative for
    any type of website (they approve all websites),
    for more info simply search in gooogle: boorfe’s tips monetize your website

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.