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
ldap1.mi.hdm-stuttgart.de
.
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!
Tip
-
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:<dependencies> <dependency> <groupId>org.ldaptive</groupId> <artifactId>ldaptive</artifactId> <version>find my current version on Maven central</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.21</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>1.7.21</version> </dependency> </dependencies>
The idea is reading your own LDAP entry and write the corresponding attributes according to the following rules:
-
If an attribute is of binary type just output its name omitting the value(s).
Tip
LdapAttribute
.isBinary()
is your friend. -
If an attribute is single valued write its name and value to standard output.
Tip
Read
LdapAttribute
.getName()
,LdapAttribute
.size()
andLdapAttribute
.getStringValue()
. -
If an attribute is multivalued write its name and all values among with a corresponding index to standard output.
Tip
Read
LdapAttribute
.getStringValues()
.
If your DN was uid=mistudent,
ou=userlist, dc=hdm-stuttgart, dc=de
the result should look
like:
mail: mistudent@mi.hdm-stuttgart.de
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:
-
Maven module source code available at
Sdi/ReadMyData
.
Notice: The above project will read the required password from a
de.hdm_stuttgart.mi.sdai.readmydata.messages.properties
file corresponding to
src/main/java/de/hdm_stuttgart/mi/sdai/readmydata/messages.properties
.
Due to password protection this file has been excluded from versioning.
You will however find messages.properties.template
next to the intended location containing the appropriate property key
name. Using your own account data should enable you running the
application.
Caution
Do not miss changing the value of
ReadMyLdap.bindDn
!