Today I worked on a Jelly script to import users to Jira. Such a script you can create automatically using a scripting language of your choice, in my case I try Python. The primary source for the users and groups data would be an organically grown LDAP of a public organization.
I had to find out that there is more about LDAP (Version 3) queries or filters (described in RFC 4515 ) then just the straight forward examples like:
(objectclass=inetorgperson)
- finds all entries with objectClass equal to inteOrgPerson
(cn=*Inter*)
- finds all entries with “Inter” appearing somewhere within the cn (common name) attribute
(!(cn=*Inter*))
- finds all entries without “Inter” appearing somewhere within the cn (common name) attribute
(&(ou=universit*)(l=Berlin))
- finds all entries with ou starting with “universit” AND l equal to Berlin (trying to find universities located in Berlin)
(&(|(ou=universit*)(ou=hochschule*))(l=Berlin))
- now we added an OR ( | ) to the query to find entries with “universit” or “hochschule” in ou (organizational unit), cause “hochschule” means literally “high school” in german, i.e. “almost” a university
I find useful to know:
(&(objectClass=inetorgperson)(mail=*))
- finds inetOrgPersons with nonempty mail attribute
(&(objectClass=inetorgperson)(!(mail=*)))
- finds the same but with an empty mail attribute
More complex queries (extensible match search):
(ou:dn:=bibliotheken)
- matches part of a dn (or better: treat attributes used within dn’s string as if they would be regular attributes of the entry) in that case entries like that: dn=…,ou=bibliotheken,dc=mydomain,dc=de
(ou:dn:=bibliotheken*)
- does not work!
General matching rules can be used (see RFC 4517) within the extensible match search. Match rules are identified by OIDs or names. So:
(uid:2.5.13.5:=John)
is the same as
(uid:caseExactMatch:=John)
And
(uid=John)
the same as
(uid:caseIgnoreMatch:=john)
or
(uid:2.5.13.2:=john)
To escape characters which have a special meaning use
‘*’ – \2a, ‘(‘ – \28, ‘)’ – \29, ‘\’ – \5c, ‘NUL’- \00, ‘/’ – \2f .
(cn=*\2a*)
- finds entries with “cn” attribute containing a value with the character “*” anywhere in it.