I have the following directory structure and am using ODM with Spring LDAP (v 2.3.1.RELEASE).
The below is the directory structure am dealing with.
dc=example,dc=com
dc=studentBase,dc=example,dc=com
I declared the base for the ldap context source in the config.xml as follows:
<ldap:context-source
id="ldapContextSource"
url="ldap://ldaphost:389"
username="cn=ldaptestadmin,cn=Administrators,cn=config"
password="abcxyz"
base="dc=studentBase,dc=example,dc=com"/>
<ldap:ldap-template id="ldapTemplate" context-source-
ref="ldapContextSource"/>
To explain the context of the problem, here are the details: I have two organizational units under studentBase as follows:
ou=groups,dc=studentBase,dc=example,dc=com
ou=people,dc=studentBase,dc=example,dc=com
Each entry inside the ou=people
is as follows:
objectclass: inetorgperson (structural)
objectclass: organizationalPerson (structural)
objectclass: person (structural)
objectclass: top (abstract)
cn: Test Name
sn: Test
givenName: TestName
uid: test1234
userPassword: <SSHA hashed password>
I created a bean annotated with @Entry as follows:
@Entry(objectClasses = {"inetOrgPerson", "organizationalPerson", "person", "top" }, base = "ou=people")
public class Student {
@Id
private Name dn;
...
...
...
}
Now when I try create the student entry inside the LDAP like below
Student objStudent = new Student();
String dn = "uid=testUserName";
Name dnName = new LdapName(dn);
objStudent.setDn(dnName);
ldapTemplate.create(objStudent);
it is not getting created under the ou=people but instead getting created in the base dn which is (dc=studentBase,dc=example,dc=com) as mentioned in the config.xml.
Per Entry javadocs, it says for the base attribute as follows : The base DN of this entry. If specified, this will be prepended to all calculated distinguished names for entries of the annotated class.
Doesn't it mean it should prepend ou=people for the @Id field of the Student??
However, in the above code, if I explicitly set the ou=person for the dn attribute, it is getting created under ou=person, no matter if I have the base attribute in @Entry or not.
String dn = "uid=testUserName,ou=person";
Name dnName = new LdapName(dn);
Am I not using the "base" attribute of @Entry annotation in the right perspective?
Or can someone explain what am getting wrong here?
Or is this used along with @DnAttribute?
Thanks.