Score:0

ldapsearch Or other means to verify users

cn flag

I tried a few answers on ldapsearch usage and yet couldn't authenticate with the ldap service from a linux server. I am not sure what parameters to use? I am trying this command

ldp=ldap://ldap.xyz.com
user=joe.john 
ldapsearch -x -D "uid=$user,dc=xyz,dc=com" \
           -W -H $ldp -b "dc=xyz,dc=com" \
           -s sub 'uid=$user'

Error :
Enter LDAP Password: 
ldap_bind: Invalid credentials (49)
        additional info: Unable to bind to the Directory Server as user uid=joe.john,dc=xyz,dc=com because no such user exists in the server

I am not sure of the above parameters , though I tried various options I am not sure who to ask in the current organization. Once I authenticate myself, I also need to verify a few other user ids using same command or other means.

Score:0
in flag

The ldapsearch syntax looks good, so it should work.

The first thing (however trivial) is to check if you use the correct password.

If you absolutely sure you gave the correct password, then you maybe specified your user incorrectly. When binding to LDAP, you need to give the exact DN of your user. You gave uid=$user,dc=xyz,dc=com, which is odd-looking to me (though syntactically correct), since users usually reside somewhere "deeper", in their own ou. So if your user's DN is actually uid=$user,ou=users,ou=auth,dc=xyz,dc=com, then you can't bind with the one you used.

If the DN is correct, you might want to try adding the -Z option (which issues StartTLS), or using ldaps instead of ldap. Perhaps the LDAP directory is configured to reject any authentications attempted on a non-encrypted connection.

Sriram avatar
cn flag
thanks for your answer. I have no idea what is DN actually. Is there any command to get this info? OR, is there any file's (such as under etc or such) content I should look for to know how to make a query? Etc
in flag
DN stand for "Distinguished Name", and it is (in the case of LDAP) something like `uid=user,ou=unit,dc=domain,dc=com`. There is no way to guess this if you don't know the structure of the LDAP database. You should ask the administrators of the LDAP server for more info.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.