Working with templates to manipulate the filter definition by runtime

Assume you have a custom text file with some objects where you want to read some special attributes from the directory service. The public directory service of the University of Michigan will be used in this example.

The goal is to read some special attributes of objects based on a plain text file. The category user defined search in the profile assistant will be selected. The search looks like this:

(&(objectClass=rfc822MailGroup)(cn=*%s*)(associatedDomain=itd.umich.edu))

This means that, all objects with the objectClass attribute "rfc822MailGroup" and the "cn" attribute containing the string in the template file will be listed in the application window. Every line in the file defines a new search request. Three different requests will be executed when the file has three lines, for example. The result is shown in the main window of the application.

(&(objectClass=rfc822MailGroup)(cn=*hostmaster*)(associatedDomain=itd.umich.edu))

You can optimize the performance when requesting only the desired attributes.

Thumbnail image for ~/images/cont/articles/en/ldap-template-en.png

First of all you will add the attribute to the local schema, you create a new category with the attributes associatedDomain and dn (see the example above). The profile configuration will now be changed from load all attributes category to the new created category associatedDomain.

The configuration UniversityofMichigan_SSL will be saved. The request considers two attributes now. The result is:

dn associatedDomain cn
cn=hostmaster,ou=System Groups,ou=Groups,dc=umich,dc=edu umich.edu itd.umich.edu hostmaster dns-maintenance hostmasters

When you modify the filter as follows:

(&(objectClass=rfc822MailGroup)(cn=*%s*)(associatedDomain=umich.edu)

The result set contains 5 hits:

dn associatedDomain cn
cn=hostmaster,ou=System Groups,ou=Groups,dc=umich,dc=edu umich.edu itd.umich.edu hostmaster dns-maintenance hostmasters
cn=bfhostmaster,ou=User Groups,ou=Groups,dc=umich,dc=edu umich.edu bfhostmaster
cn=lsa hostmaster,ou=User Groups,ou=Groups,dc=umich,dc=edu umich.edu lsa-hostmaster lsa hostmaster
cn=UMMC-Hostmaster,ou=User Groups,ou=Groups,dc=umich,dc=edu umich.edu UMMC-Hostmaster UMMC Hostmaster umhs-hostmaster med-hostmaster med hostmaster
cn=ieee-hostmaster,ou=User Groups,ou=Groups,dc=umich,dc=edu umich.edu ieee-hostmaster

When you specify the pattern as follows:

(&(objectClass=rfc822MailGroup)(cn=*%s*)(associatedDomain=*)

The result set contains all the objects having the attribute associatedDomain. When you assume only the strings "umich.edu" and "itd.umich.edu" are possible, the search request contain all objects having the attribute associatedDomain with both strings. Having templates available makes it very easy to collect different LDAP search request in a one final result set. A visualization of the result set will be shown in the example "Statistics in XML-format".

Navigation Links