Apache Directory Project - Directory Partitions Question

This is Interesting: Free IT Magazines  
Home > Archive > Apache Directory Project > February 2006 > Directory Partitions Question





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Directory Partitions Question
Ole Ersoy

2006-02-26, 5:45 pm

Hey Guys,

I'm testing out adding a partition for
dc=apache,dc=org in RC1.

I added it right beneath dc=example,dc=com in the
server.xml file.

When I try to create a context beneath
dc=example,dc=com
no problemo, the unit test runs smooth.

However, when running it for dc=apache,dc=org, not so
smooth.

Originally I took the dc=apache,dc=org entry from the
"Partition" documentation. I had to change the Spring
class attribute (Which I updated in the documentation)
to match the one used in the dc=example,
configuration, otherwise the server complained during
startup in debug mode.

I also changed the indexAttributes elements to match
the ones in dc=example.

Now I make the corresponding changes in the unit test,
aaaand fire it up! All red. Actually I don't even
get a red, just the console in Eclipse.

I looked through the configuration file, to see if
there was some other element that was making the
dc=example partition work. I could not find one. Is
there one?

Here is the dc=apache configuration element I added
(Including the example one just for reference):

<bean id="examplePartitionConfiguration"
class="org.apache.directory.server.core.configuration.MutableDirectoryPartitionConfiguration">
<property
name="name"><value>example</value></property>
<property
name="suffix"><value>dc=example,dc=com</value></property>
<property name="indexedAttributes">
<set>
<value>dc</value>
<value>ou</value>
<value>objectClass</value>
<value>krb5PrincipalName</value>
<value>uid</value>
</set>
</property>
<property name="contextEntry">
<value>
objectClass: top
objectClass: domain
objectClass: extensibleObject
dc: example
</value>
</property>
</bean>


<!-- Additional ContextPartitionConfiguration -->
<bean id="apachePartitionConfiguration"
class="org.apache.directory.server.core.configuration.MutableDirectoryPartitionConfiguration">
<property
name="name"><value>apache</value></property>
<property
name="suffix"><value>dc=apache,dc=org</value></property>
<property name="indexedAttributes">
<set>
<value>dc</value>
<value>ou</value>
<value>objectClass</value>
<value>krb5PrincipalName</value>
<value>uid</value>
</set>
<property name="contextEntry">
<value>
objectClass: top
objectClass: domain
objectClass: extensibleObject
dc: apache
</value>
</property>
</bean>

And here is the unit test code:

package com.pyramidetechnologies.webapp.mdc;

import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.Name;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;

import junit.framework.TestCase;

public class TestNewContextSetup extends TestCase {

public DirContext authenticate() {
try {
Hashtable<String, String> env = new
Hashtable<String, String>();
// Set up the environment for creating the initial
context
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL,
"ldap://localhost:389/dc=apache,dc=org");

// Authenticate as S. User and password "mysecret"
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL,
"uid=admin,ou=system");
env.put(Context.SECURITY_CREDENTIALS, "secret");

DirContext ctx = new InitialDirContext(env);

ctx.createSubcontext("mail=ole-sg9fheiuwuRtdF/iL03xVDBc0kxJFkfs@public.gmane.org");

ctx.destroySubcontext("mail=ole-sg9fheiuwuRtdF/iL03xVDBc0kxJFkfs@public.gmane.org");
return ctx;
} catch (NamingException e) {
e.printStackTrace();
return null;
}
}

public void testAddContext() throws NamingException {
DirContext ctx=authenticate();
Name ole = null;
//ctx.destroySubcontext("pyramide technologies");
//ctx.bind(ole,
ctx.lookup("mail=ole-sg9fheiuwuRtdF/iL03xVDBc0kxJFkfs@public.gmane.org"));

//ctx.destroySubcontext("mail=ole-sg9fheiuwuRtdF/iL03xVDBc0kxJFkfs@public.gmane.org");
}
}

Any idea on what I'm missing?

Thanks,
- Ole

________________________________________
__________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Stefan Zoerner

2006-02-26, 5:45 pm

Ole Ersoy wrote:

> I'm testing out adding a partition for
> dc=apache,dc=org in RC1.
>
> I added it right beneath dc=example,dc=com in the
> server.xml file.
>
> When I try to create a context beneath
> dc=example,dc=com
> no problemo, the unit test runs smooth.
>
> However, when running it for dc=apache,dc=org, not so
> smooth.
>
> Originally I took the dc=apache,dc=org entry from the
> "Partition" documentation. I had to change the Spring
> class attribute (Which I updated in the documentation)
> to match the one used in the dc=example,
> configuration, otherwise the server complained during
> startup in debug mode.
>
> I also changed the indexAttributes elements to match
> the ones in dc=example.
>
> Now I make the corresponding changes in the unit test,
> aaaand fire it up! All red. Actually I don't even
> get a red, just the console in Eclipse.
>
> I looked through the configuration file, to see if
> there was some other element that was making the
> dc=example partition work. I could not find one. Is
> there one?


Hello Ole!

Adding an element for the partition is not enough. If you look at the

<bean id="examplePartitionConfiguration"
class="...server.core.configuration.MutableDirectoryPartitionConfiguration">
....

partition of the default server.xml, this bean as an id
"examplePartitionConfiguration", which is used in the bean with id
"configuration" in a property like this:

<property name="contextPartitionConfigurations">
<set>
<ref bean="examplePartitionConfiguration"/>
</set>
</property>


Have you added a corresponding entry for your
apachePartitionConfiguration, i.e.

<property name="contextPartitionConfigurations">
<set>
<ref bean="examplePartitionConfiguration"/>
<ref bean="apachePartitionConfiguration"/>
</set>
</property>

This might be the problem.

Hope this helps + Greetings from Hamburg
Stefan



Stefan Zoerner

2006-02-26, 5:45 pm

Hi Ole!

Ole Ersoy wrote:
> Stefan,
>
> Thanks! Works like a dream now!


Nice to hear that. Should add an instruction for that to the tutorial
(trail "How to begin").

> The tutorial skeleton is looking pretty solid by the
> way. I started playing with jexplorer a little, and
> I'll add my notes when I get a chance.
>
> Should I send them to you for review or just put them
> in the document directly?


I guess it is easier if you contribute to Confluence directly. This is
what a wiki is for, and currently I do not have enough time for the
tutorial anyway. I have to finish a portlet book until and of march.
After that I plan to create some more content for the tutorial. But the
whole tutorial with all the topics is probably too ambitious for me
alone -- support is definitely appreciated!

Greetings from Hamburg,
Stefan


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com