You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Jonathan Russell <jo...@us.ibm.com> on 2012/12/12 22:45:41 UTC
[Apache DS] creating a domain partition.
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 );
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:
org.apache.directory.shared.ldap.exception.LdapSchemaViolationException:
Required attributes [2.5.4.10] not found within entry dc=sevenseas
at
org.apache.directory.server.core.schema.SchemaInterceptor.assertRequiredAttributesPresent(SchemaInterceptor.java:2199)
at
org.apache.directory.server.core.schema.SchemaInterceptor.check(SchemaInterceptor.java:1965)
at
org.apache.directory.server.core.schema.SchemaInterceptor.add(SchemaInterceptor.java:2054)
at
org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196)
at
org.apache.directory.server.core.operational.OperationalAttributeInterceptor.add(OperationalAttributeInterceptor.java:202)
at
org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196)
at
org.apache.directory.server.core.changelog.ChangeLogInterceptor.add(ChangeLogInterceptor.java:109)
at
org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196)
at
org.apache.directory.server.core.exception.ExceptionInterceptor.add(ExceptionInterceptor.java:167)
at
org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196)
at
org.apache.directory.server.core.interceptor.BaseInterceptor.add(BaseInterceptor.java:129)
at
org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196)
at
org.apache.directory.server.core.authz.AciAuthorizationInterceptor.add(AciAuthorizationInterceptor.java:455)
at
org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196)
at
org.apache.directory.server.core.referral.ReferralInterceptor.add(ReferralInterceptor.java:251)
at
org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196)
at
org.apache.directory.server.core.authn.AuthenticationInterceptor.add(AuthenticationInterceptor.java:212)
at
org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196)
at
org.apache.directory.server.core.normalization.NormalizationInterceptor.add(NormalizationInterceptor.java:126)
at
org.apache.directory.server.core.interceptor.InterceptorChain.add(InterceptorChain.java:756)
at
org.apache.directory.server.core.DefaultOperationManager.add(DefaultOperationManager.java:260)
at
org.apache.directory.server.core.interceptor.context.AbstractOperationContext.add(AbstractOperationContext.java:300)
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");
Which produced this exception:
org.apache.directory.shared.ldap.exception.LdapSchemaViolationException:
Attribute dc not declared in objectClasses of entry dc=sevenseas
at
org.apache.directory.server.core.schema.SchemaInterceptor.assertAllAttributesAllowed(SchemaInterceptor.java:2138)
at
org.apache.directory.server.core.schema.SchemaInterceptor.check(SchemaInterceptor.java:1970)
at
org.apache.directory.server.core.schema.SchemaInterceptor.add(SchemaInterceptor.java:2054)
at
org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196)
at
org.apache.directory.server.core.operational.OperationalAttributeInterceptor.add(OperationalAttributeInterceptor.java:202)
at
org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196)
at
org.apache.directory.server.core.changelog.ChangeLogInterceptor.add(ChangeLogInterceptor.java:109)
at
org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196)
at
org.apache.directory.server.core.exception.ExceptionInterceptor.add(ExceptionInterceptor.java:167)
at
org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196)
at
org.apache.directory.server.core.interceptor.BaseInterceptor.add(BaseInterceptor.java:129)
at
org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196)
at
org.apache.directory.server.core.authz.AciAuthorizationInterceptor.add(AciAuthorizationInterceptor.java:455)
at
org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196)
at
org.apache.directory.server.core.referral.ReferralInterceptor.add(ReferralInterceptor.java:251)
at
org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196)
at
org.apache.directory.server.core.authn.AuthenticationInterceptor.add(AuthenticationInterceptor.java:212)
at
org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196)
at
org.apache.directory.server.core.normalization.NormalizationInterceptor.add(NormalizationInterceptor.java:126)
at
org.apache.directory.server.core.interceptor.InterceptorChain.add(InterceptorChain.java:756)
at
org.apache.directory.server.core.DefaultOperationManager.add(DefaultOperationManager.java:260)
at
org.apache.directory.server.core.interceptor.context.AbstractOperationContext.add(AbstractOperationContext.java:300)
I'm not sure how to proceed. I saw this thread in the message board:
http://mail-archives.apache.org/mod_mbox/directory-dev/200809.mbox/%3C48D14DFC.6070201@apache.org%3E
But when I add that to the top of my ldif, it seems to have no affect on
the behavior at runtime. I suspect the problem in my code is small, but I
have no idea where it is. Has anyone encountered this or understand what
I'm doing wrong?
Thanks,
Jon
Re: [Apache DS] creating a domain partition.
Posted by Emmanuel Lécharny <el...@gmail.com>.
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