Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do ldapsearch with multiple filters?

I am doing an ldap search like below to get the info for a person,

ldapsearch -LLL -H ldaps://ldap.xyzcorp.com:636 -D 'xyzcorp\jack1' -W -x -b 'dc=xyzcorp,dc=com' sn=Ready

"sn" name "Ready" here is the last name of the person, but it returns multiple results who have the same last name "Ready", so I want to add multiple filters to search for both first name and last name like below:

ldapsearch -LLL -H ldaps://ldap.xyzcorp.com:636 -D 'xyzcorp\jack1' -W -x -b 'dc=xyzcorp,dc=com' sn=Ready AND givenName=Bill

but the result returned still contains multiple persons with the same last name "Ready". I am not sure which part is incorrect.

Can you please help me with this command?

like image 949
flyingbee Avatar asked Oct 22 '25 05:10

flyingbee


1 Answers

I haven't used ldapsearch. That said, the custom LDAP query to return only the one person with sn=Ready and givenName=Bill if you can tack that onto your command would look like:

ldapsearch -LLL -H ldaps://ldap.xyzcorp.com:636 -D 'xyzcorp\jack1' -W -x -b 'dc=xyzcorp,dc=com' "(&(objectCategory=user)(objectClass=user)(sn=Ready)(givenName=Bill))"

like image 79
T-Heron Avatar answered Oct 23 '25 21:10

T-Heron