You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@directory.apache.org by Andrew Wiley <de...@gmail.com> on 2010/04/13 22:10:38 UTC

Adding an objectClass to an Entry

I'm trying to figure out how to add an objectClass to an entry in the
directory, but I seem to be misunderstanding how modifications should work.
I'm trying something like this:
AttributeType attr = new AttributeType("objectClass");
Modification mod = new
ServerModification(ModificationOperation.ADD_ATTRIBUTE, new
DefaultServerAttribute(attr, "javaObject"));

The problem is that attr.getSyntax() is returning null, but I'm not sure
what the AttributeType should be if not objectClass. How should I be doing
this?

Any help is appreciated,
Andrew Wiley

Re: Adding an objectClass to an Entry

Posted by Kiran Ayyagari <ay...@gmail.com>.
>> Should I be using the ServerModificaton classes if my directory is
> embedded?
not necessarily, I assume that you are using CoreSession (obtained via
dirService.getAdminSession() or
getSession( userPrincipal ) method calls)

Kiran Ayyagari

Re: Adding an objectClass to an Entry

Posted by Andrew Wiley <de...@gmail.com>.
On Tue, Apr 13, 2010 at 3:22 PM, Kiran Ayyagari <ay...@gmail.com>wrote:

> hi Andrew,
>
> On Tue, Apr 13, 2010 at 11:10 PM, Andrew Wiley <de...@gmail.com> wrote:
> > I'm trying to figure out how to add an objectClass to an entry in the
> > directory, but I seem to be misunderstanding how modifications should
> work.
> > I'm trying something like this:
> > AttributeType attr = new AttributeType("objectClass");
> > Modification mod = new
> > ServerModification(ModificationOperation.ADD_ATTRIBUTE, new
> > DefaultServerAttribute(attr, "javaObject"));
> the attributeType in ApacheDS is not created manually rather obtained
> through a lookup operation on
> SchemaManager like
> dirService.getSchemaManager().lookupAttributeTypeRegistry(
> "objectClass" )
>
> having said that, you can create a modification in a rather easy way
> by using ClientModification and DefaultClientAttribute classes as
> shown below
>
>        EntryAttribute attribute = new DefaultClientAttribute(
> "objectClass", "javaObject" );
>        ClientModification cm = new ClientModification(
> ModificationOperation.ADD_ATTRIBUTE, attribute );
>
> Should I be using the ServerModificaton classes if my directory is
embedded?

Thanks,
Andrew Wiley

Re: Adding an objectClass to an Entry

Posted by Kiran Ayyagari <ay...@gmail.com>.
hi Andrew,

On Tue, Apr 13, 2010 at 11:10 PM, Andrew Wiley <de...@gmail.com> wrote:
> I'm trying to figure out how to add an objectClass to an entry in the
> directory, but I seem to be misunderstanding how modifications should work.
> I'm trying something like this:
> AttributeType attr = new AttributeType("objectClass");
> Modification mod = new
> ServerModification(ModificationOperation.ADD_ATTRIBUTE, new
> DefaultServerAttribute(attr, "javaObject"));
the attributeType in ApacheDS is not created manually rather obtained
through a lookup operation on
SchemaManager like
dirService.getSchemaManager().lookupAttributeTypeRegistry(
"objectClass" )

having said that, you can create a modification in a rather easy way
by using ClientModification and DefaultClientAttribute classes as
shown below

        EntryAttribute attribute = new DefaultClientAttribute(
"objectClass", "javaObject" );
        ClientModification cm = new ClientModification(
ModificationOperation.ADD_ATTRIBUTE, attribute );

HTH

Kiran Ayyagari