directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lécharny <elecha...@gmail.com>
Subject Re: [Apache DS] creating a domain partition.
Date Wed, 12 Dec 2012 22:32:34 GMT
Le 12/12/12 10:45 PM, Jonathan Russell a écrit :
> I'm using an embedded Apache DS 1.5

> (so I have no server.xml, as far as 
> I'm aware), and I'm trying to programmatically add a domain to my root 
> partition. I've seen the instructions here:
> http://directory.apache.org/apacheds/1.5/144-adding-your-own-partition-resp-suffix.html
>
> They have an end result that I'm looking for "dc=example, dc=com", but 
> they don't explain how that's created.
>
> I see the instructions for adding a partition: 
>
> JdbmPartition sevenseasPartition = new JdbmPartition();
> sevenseasPartition.setId("sevenseas");
> sevenseasPartition.setSuffix("o=sevenseas");
> sevenseasPartition.setCacheSize(1000);
> sevenseasPartition.init(directoryService);
>
> // Create some indices (optional)
> Set<Index<?,ServerEntry>> indexedAttrs = new HashSet<Index<?, 
> ServerEntry>>();
> indexedAttrs.add( new JdbmIndex<Object, ServerEntry>("objectClass"));
> indexedAttrs.add( new JdbmIndex<Object, ServerEntry>("o"));
> sevenseasPartition.setIndexedAttributes( indexedAttrs );
>
> //Add partition to the directory service
> directoryService.addPartition(sevenseasPartition);
>
> // start the directory service
> directoryService.startup();
>
> // create the context entry
> ServerEntry entry = new DefaultServerEntry( 
> directoryService.getRegistries(), new LdapDN( "o=sevenseas") );
> entry.put( "objectClass",  "top", "organization" );
> entry.put("o","sevenseas");
>
> // add the context entry
> AddContextPartitionOperationContext adOpContext = new 
> AddContextPartitionOperationContext( directoryService.getAdminSession(), 
> sevenseasPartition );
> adOpContext.add( entry, null );
> directoryService.getPartitionNexus().addContextPartition( adOpContext );

So far so good.


>
> However, simply changing "o" to "dc" doesn't create a domain of 
> "sevenseas" as I expected. If I run this code:
>            JdbmPartition sevenseasPartition = new JdbmPartition ();
>             sevenseasPartition.setId ("sevenseas");
>             sevenseasPartition.setSuffix ("dc=sevenseas");
>             sevenseasPartition.setCacheSize (1000);
>             sevenseasPartition.init (service);
>
>             // Create some indices (optional)
>             Set<Index<?, ServerEntry>> indexedAttrs = new HashSet<Index<?,

> ServerEntry>> ();
>             indexedAttrs.add (new JdbmIndex<Object, ServerEntry> (
> "objectClass"));
>             indexedAttrs.add (new JdbmIndex<Object, ServerEntry> ("dc"));
>             sevenseasPartition.setIndexedAttributes (indexedAttrs);
>
>             //Add partition to the directory service
>             service.addPartition (sevenseasPartition);
>
>             // start the directory service
>             service.startup ();
>
>             // create the context entry
>             ServerEntry entry = new DefaultServerEntry (service
> .getRegistries () , new LdapDN ("dc=sevenseas"));
>             entry.put ("objectClass", "top", "organization");
>             entry.put ("dc", "sevenseas");
>             // add the context entry
>             /*
>              * AddContextPartitionOperationContext adOpContext = new
>              * AddContextPartitionOperationContext 
> (service.getAdminSession () ,
>              * sevenseasPartition); adOpContext.add (entry, null);
>              * service.getPartitionNexus ().addContextPartition 
> (adOpContext);
>              */
>
> than I get a naming context created in my root, as I expect. But when I 
> uncomment out the bottom part (thus adding the context entry), I get an 
> exception:


Plain normal. You can't add the 'dc' Attribute if the ObjectClass does
not allow that. So far, you have declared 'top' and 'oganization' as
ObjectClasses for teh added entry, you then can't inject a 'dc'
attribute. You must add the 'dcObject' if you want to be able to add the
'dc' Attribute. Or you can also use 'domain' instead of 'organization'
> Seeing that 2.5.4.10 is the "o" that was used in the example, I added it 
> back in: 
>             ServerEntry entry = new DefaultServerEntry (service
> .getRegistries () , new LdapDN ("dc=sevenseas"));
>             entry.put ("objectClass", "top", "organization");
>             entry.put ("dc", "sevenseas");
>             entry.put ("o", "something");

See above.
>


-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com 


Mime
View raw message