This article shows how to extract data from an LDAP server to a CSV file. 

Stambia can do this kind of extraction with the "TOOL Ldap Extractor (search)", which is available from the "templates.generic" Templates package.


Source Ldap structure

We are going to unload data from a LDAP Organization Unit named "ou=customers,ou=support,dc=example,dc=com". 

It contains object of class "person", for example: 

 


Designing the Target file

The "TOOL Ldap Extractor" will match the LDAP attribute names to the target file's field names. 

So we need to design our File Metadata so that the fields names reflect the LDAP attributes. 

As you can see in the LDAP structure, some attributes contain special characters (semi-colons in order to suffix the language variant). 

Our File Metadata will hold this exact name in the Field name property, and we will specify a different Physical Name, without special characters. 

For example : 


Setting up the Process

The process contains the "TOOL Ldap Extractor (search)", on which we drag and dropped the Ldap metadata and File metadata.

The tool is configured like this: 

  • truncateTargetFile: true (we want to rewrite the file from scratch at each execution)
  • searchContext: ou=customers,ou=support (this Ldap path will be added to the Ldap URL from the metadata)
  • filterExpression: (objectClass=person) (here, we specify that we want only objects of class Person)
  • dnFieldName: pathName (name of the field from the File Metadata which will store the Ldap identifier relative to the searchContext)
  • matchLdapAttributesWith: logical name (we defined the exact attribute names in the Name of each Field, not in the physical name)
  • generateHeader: true (we want to generate a header line in the target file)



Execution


After execution, here is a sample result in the CSV file:

pathName,cn,sn,description;lang-fr-fr,description;lang-en-us
"cn=GIBBS Jason","GIBBS Jason","GIBBS","Monsieur","Mister"
"cn=O'NEAL Michael","O'NEAL Michael","O'NEAL","Monsieur","Mister"
"cn=JIMENEZ Tony","JIMENEZ Tony","JIMENEZ","Monsieur","Mister"
"cn=HAMPTON Lionel","HAMPTON Lionel","HAMPTON","Monsieur","Mister"
"cn=SILL Joel","SILL Joel","SILL","Monsieur","Mister"
"cn=CARTER Rick","CARTER Rick","CARTER","Monsieur","Mister"
"cn=BARTZ Gary","BARTZ Gary","BARTZ","Monsieur","Mister"
"cn=REEVES Diane","REEVES Diane","REEVES","Madame","Madam"
"cn=JOHNSTON Joanna","JOHNSTON Joanna","JOHNSTON","Madame","Madam"