How to do ldapsearch with multiple filters?

15,426

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

Share:
15,426
flyingbee
Author by

flyingbee

Updated on June 06, 2022

Comments

  • flyingbee
    flyingbee almost 2 years

    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?