0
votes

I have text file, on each line there is ldap attribute taken from my LDAP, the attribute is 'uid', it looks like first and second name (example -> john.carter), so what I want to do is to write a bash script which will compare the uid's from the text file to the uid's from specific group of people in ldap and if there is a match I want to print another attribute from that group. My problem is with the comparison, i.e how to match the uid's from the text file to those from the Ldap. Any suggestions?

This is my ldapsearch: ldapsearch -H ldap://server -D "uid=name,ou=group,dc=some,dc=domain,dc=com" -w "example" -b "o=organizationName,ou=group,dc=some,dc=domain,dc=com" I suppose that it should be done with 'while - do,done' cycle, so the question is how to check if the uid's from:'o=organizationName,ou=group,dc=some,dc=domain,dc=com' are matched with the uid's from the text file, where in the text file they are sorted one uid on line: test.test test1.test1 ...

1
And what have you got so far?sjsam
This is my ldapsearch: ldapsearch -H ldap://server -D "uid=name,ou=group,dc=some,dc=domain,dc=com" -w "example" -b "o=organizationName,ou=group,dc=some,dc=domain,dc=com" I suppose that it should be done with 'while - do,done' cycle, so the question is how to check if the uid's from:'o=organizationName,ou=group,dc=some,dc=domain,dc=com' are matched with the uid's from the text file, where in the text file they are sorted one uid on line: test.test test1.test1 ...N.N
Thanks. Copy the stuff from the comment and paste in the question.sjsam
thanks for the assistanceN.N

1 Answers

0
votes

Depending on how many lines there are in the file you could collect them into an or statement like (|(uid=john.carter)(uid=jane.carter)(uid=... and then add the rest of your criteria. The result would look something like this:

(&(|(uid=john.carter)(uid=jane.carter)(uid=john.doe))(memberOf=o=organizationName,ou=group,dc=some,dc=domain,dc=com))

If there are too many then you could create a query for each line like this:

(&(uid=john.carter)(memberOf=o=organizationName,ou=group,dc=some,dc=domain,dc=com))
(&(uid=jane.carter)(memberOf=o=organizationName,ou=group,dc=some,dc=domain,dc=com))
(&(uid=john.doe)(memberOf=o=organizationName,ou=group,dc=some,dc=domain,dc=com))

Then you would need to run each query specifying the fields you want to be returned.