flyingbee
flyingbee

Reputation: 621

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?

Upvotes: 3

Views: 24878

Answers (1)

T-Heron
T-Heron

Reputation: 5584

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))"

Upvotes: 11

Related Questions