Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ldapsearch with username and password

Here is my LDAP ORG Structure:

LDAP ORG Structure

I created user with first, last name with password. But it is not working when am trying to connect using jdbc. Error says invalid credentials. Then I tried ldapsearch as follows:

I followed this process for users and group creation:

root@ip:/home# ldapwhoami
SASL/DIGEST-MD5 authentication started
Please enter your password:
ldap_sasl_interactive_bind_s: Invalid credentials (49)
    additional info: SASL(-13): user not found: no secret in database

root@ip:/# ldapsearch -x -LLL -h ip -D username -w password -b"cn=admin,dc=ivhdev,dc=local" -s sub "(objectClass=*)" "givenName=username*"
ldap_bind: Invalid DN syntax (34)
    additional info: invalid DN

Please suggest/correct me, if am passing the right info in DN syntax. I am unable to validate the user credentials with their name and password.

like image 505
jack Avatar asked Mar 16 '17 21:03

jack


People also ask

How do I authenticate ldapsearch?

The easiest way to search LDAP is to use ldapsearch with the “-x” option for simple authentication and specify the search base with “-b”. If you are not running the search directly on the LDAP server, you will have to specify the host with the “-H” option.

What is ldapsearch command?

ldapsearch is a command-line tool that opens a connection to an LDAP server, binds to it, and performs a search using a filter. The results are then displayed in the LDIF. Note. The LDIF is used to represent LDAP entries in a simple text format.

How do I get a list of LDAP users?

I get list of all the users of LDAP using the following command ldapsearch -x -LLL uid=* > result . There is a complete list of these records.


2 Answers

The -D option takes the DN for logging in to your LDAP server.

The -b option takes the search base in your LDAP tree where you want to search for the user's given name.

So, your ldapsearch command becomes:

ldapsearch -x -LLL -h ip -D 'cn=admin,dc=ivhdev,dc=local' -w password -b 'dc=users,dc=local' -s sub '(objectClass=*)' 'givenName=username*'
like image 55
anacron Avatar answered Sep 20 '22 13:09

anacron


If you use the Apache Directory Studio (http://directory.apache.org/studio/) you can see the actual ldapsearch commands used by the application. Maybe this is useful for anyone.

like image 28
aemaem Avatar answered Sep 18 '22 13:09

aemaem