Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have to query attributes for about 10 000 users. I have an ldapsearch query that works for a single user. Here is the releveant part, where I search for the objectGUID attribute of user abc123 :

ldapsearch -h somehost.com -D "CN=valid_user,DC=valid_everything" -q -b "OU=valid_ou,DC=valid_dc" -s sub "cn=abc123" -L objectGUID 

I would like to put all my queries in a file, and use the -f myqueries.txt option. Since this query will be carried out over SSL, I would like to avoid the 10k SSL negotiations I would get if I was to run 10k separate ldapsearch.

I tried with a file that looks like this :

(cn=abc123)
(cn=lmn456)
(cn=xyz789)

With this modified command line :

ldapsearch -v -h somehost.com -D "CN=valid_user,DC=valid_everything" -q -b "OU=valid_ou,DC=valid_dc" -s sub -f myqueries.txt -L objectGUID 

But I always get an Bad search filter error.

I was not able to determine what version of ldapsearch this is. It is running on a custom Linux distribution.

How can I use the -f option to make ldapsearch use queries read from a file ?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

File should look like this:

abc123
lmn456
xyz789

and command like this:

ldapsearch -v -h somehost.com -D "CN=valid_user,DC=valid_everything" -q -b "OU=valid_ou,DC=valid_dc" -s sub -f myqueries.txt "(cn=%s)" -L objectGUID 

File given after -f can only holds parameters of query, not the query.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.