Ldap search query

Hi All,

I have a existing Ldap query which take a HOME as variable and gives the result where i grep for a particular line.

ldapsearch -h server_domain_name -p 389 -D  "uid=user,ou=appadm,o=ent" -w PaB -b  "ou=roles,o=ent"  "cidx=$HOME" | grep -w "ent: xyz"

Now i have 330K Homes in a text file '/opt/home/dir/homes.txt' , by passing the Home to the Ldap search from a loop is taking lot of time.
Is there any way possible that we can pass whole file and grep the value(ent: xyz) associated for the home .

The output should be "ent:xyx | $HOME" in a file

Thanks in advance .

Sorry today is my first day dealing with ldap

Well you could fetch all the users with a non blank cidx first:

ldapsearch -h server_domain_name -p 389 -D  "uid=user,ou=appadm,o=ent" -w PaB -b  "ou=roles,o=ent"  '(&objectClass=user)(cidx=*))' | grep -E '^(cidx:|ent:)' > home_list.txt

you could then process this file with awk to extract the particular HOMES you want.

1 Like