Accessing LDAP by a Java application.

Accessing LDAP requires a suitable client component. A standard JDK or JRE ships with a JNDI provider. The API however requires a lot of boilerplate code.

Ldaptive offers a promising client provider API. Start a Maven based Eclipse project which reads your own HdM LDAP data being provided by the MI replica server

This server allows for retrieving all attributes belonging to your personal records. Thus an authenticated bind using your HdM credentials is mandatory. Use TLS to prevent password sniffing!


  • Read the quick start guide and consult the Ldaptive API.

  • Using Ldaptive may be accomplished by adding the following Maven dependencies to your project's pom.xml file:


The idea is reading your own LDAP entry and write the corresponding attributes according to the following rules:

If your DN was uid=mistudent, ou=userlist, dc=hdm-stuttgart, dc=de the result should look like:

gidNumber: 31104
cn: MI Negative Testuser
objectClass[0]: posixAccount
objectClass[1]: hdmSambaDomain
objectClass[2]: hdmAccount
objectClass[3]: hdmStudent
objectClass[4]: inetOrgPerson
objectClass[5]: eduPerson
objectClass[6]: shadowAccount
loginShell: /bin/sh
Not displaying value of binary attribute 'userPassword'
hdmCategory: 1
uid: mistudent
uidNumber: 32669
shadowLastChange: 16749
homeDirectory: /home/stud/MI/mistudent
sambaNTPassword: C1E13066AA936CBF9260913EE962B8C2
sn: Testuser
matrikelNr: 98911

Solution available at:

Notice: The above project will read the required password from a file corresponding to src/main/java/de/hdm_stuttgart/mi/sdai/readmydata/ Due to password protection this file has been excluded from versioning. You will however find next to the intended location containing the appropriate property key name. Using your own account data should enable you running the application.


Do not miss changing the value of ReadMyLdap.bindDn!