directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Seelmann <>
Subject Re: [Schema] How do I write a new ObjectClass to ApacheDS
Date Wed, 28 Mar 2007 22:37:52 GMT
Ole Ersoy schrieb:
> OH - OK - I think the lights are turning on.
> Suppose I have a
> DN: cn=user1 ou=users, ou=system
> I can hang any attribute I want on this DN right?

Yes, assumed that the attribute type is defined in the LDAP schema and
the DN/entry has the object classes that allow that attribute.

> So if I want to store an instance of Java Class User (That has members
> [userName:String, userPassword:string]
> I could simply add the member values of a User instance as attributes to
> the DN, and my object is effectively stored.
> If I want to get an instance of that object later,
> the DAS just creates a user instance, and fetches the attributes using the
> DN: cn=user1 ou=users, ou=system      
> context.
> In other words I get the attributes assigned to this context and
> the ones that have the same name as the User Class members, would be
> be assigned used to initialize the state of a User instance?

Hm, JNDI defines a framework for doing such mappings between Java
objects and LDAP entries: State Factories and Object Factories. Please
see, especially
chapter 'Java Objects and the Directory'.

> So even thought userName has java type String,
> I don't have to create  a corresponding
> LDAP ObjectClass named User that says that
> userName is of LDAP attribute type String....., and then map the java
> members
> to the members of the User ObjectClass?

For such a simple case you could just reuse the standard object class
'person' with its attributes 'cn' and 'userPassword'. But note that the
userPassword attribute is defined as binary (Octet String) in RFC 4519.

If your User Java class additionally has an attribute (e.g. 'shoeSize')
that is not specified in an standard schema you could define an
additional (AUXILIARY) object class in LDAP, e.g. 'customPerson' and an
attribute type 'shoeSize' as may attribute. Then you could add this
object class to the entry and then you could store the attribute
'shoeSize' to the entry.

> Thanks,
> - Ole


View raw message