You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Lyndon Washington <ly...@gmail.com> on 2005/11/01 21:01:10 UTC
Adding a Custom Partition Context
Hi,
I have taken a look at as much wiki and website docs on the subject of
custom context partitions, but I am still running into a limitation.
I have added my own CustomPartiton which extends AbstractContextPartition. I
have some configuration settings specific to my partition, so I have also
created a new ContextPartitionConfiguration which extends
MutableContextPartitionConfiguration.
Unfortunately, in my CustomPartition.doInit() method I attempt to test if
the configuration that is returned from
AbstractContextPartition.getConfiguration() is an instance of my new
configuration, and if it is I want to use the new configuration settings to
configure the custom partition. The implementation within
DefaultContextPartitionNexus.addContextPartition() creates a new
MutableContextPartitionConfiguration and copies the known values from the
config that was passed into that method, thus by the time my code is called
it is never an instance of my new configuration class.
Is this done to alleviate some known issue, or is it just an oversight. If
it is an oversight, I can fix my local sandbox with a 'short sighted'
implementation. If this is deliberately implemented this way, how are you
supposed to use a new type of ContextPartitionConfiguration?
Any help would be most appreicated.
Cheers,
-Lyndon-
Re: Adding a Custom Partition Context
Posted by Lyndon Washington <lw...@novell.com>.
oops! and to answer your question about what I am trying to achieve . . .
I want a new configuration property for my partition so that it looks
somewhat like . . .
<bean id="examplePartitionConfigurat ion"
class="com.example.MyPartitionConfig">
<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>
<property name="integrationServiceName">
<value>org.fooorg.IntegrationProject</value>
</property>
On 11/1/05, Lyndon Washington <ly...@gmail.com> wrote:
>
> Hi Alex,
>
> Thanks for the prompt reply.
>
> I have already tried that, and it fails to pass in my configuration object
> because as I stated earlier, the "
> DefaultContextPartitionNexus.addContextPartition() creates a new
> MutableContextPartitionConfiguration" rather than using the configuration
> that was instantiated based on the properties file.
>
> I have also tried altering one of the JUnit test cases and adding the
> configuration to a Hashtable and passing that to a JNDI context
> intitialization . . . no joy there either.
>
> Here is the offending code, IMHO, which shows that the config that is
> passed in is not the one that is ultimately passed to 'partition.init()':
> <snippet>
> public synchronized void addContextPartition(
> ContextPartitionConfiguration config ) throws NamingException
> {
> ContextPartition partition = config.getContextPartition();
>
> // Turn on default indices
> MutableContextPartitionConfiguration mcfg =
> new MutableContextPartitionConfiguration();
> mcfg.setName( config.getName() );
> mcfg.setSuffix( config.getSuffix() );
> mcfg.setContextEntry( config.getContextEntry() );
> mcfg.setContextPartition( partition );
>
> Set indexedAttrs = config.getIndexedAttributes();
> indexedAttrs.add( Oid.ALIAS );
> indexedAttrs.add( Oid.EXISTANCE );
> indexedAttrs.add( Oid.HIERARCHY );
> indexedAttrs.add( Oid.NDN );
> indexedAttrs.add( Oid.ONEALIAS );
> indexedAttrs.add( Oid.SUBALIAS );
> indexedAttrs.add( Oid.UPDN );
> mcfg.setIndexedAttributes( indexedAttrs );
>
> String key = config.getSuffix();
> if( partitions.containsKey( key ) )
> {
> throw new ConfigurationException( "Duplicate partition suffix: " + key );
> }
>
> partition.init( factoryCfg, mcfg );
> partitions.put( partition.getSuffix( true ).toString(), partition );
>
> Attribute namingContexts = rootDSE.get( NAMINGCTXS_ATTR );
> namingContexts.add( partition.getSuffix( false ).toString() );
> }
> </snippet>
>
> -Lyndon-
>
>
> On 11/1/05, Alex Karasulu <ao...@bellsouth.net> wrote:
> >
> > Lyndon Washington wrote:
> >
> > ...
> >
> > > I have added my own CustomPartiton which extends
> > > AbstractContextPartition. I have some configuration settings specific
> > > to my partition, so I have also created a new
> > > ContextPartitionConfiguration which extends
> > > MutableContextPartitionConfiguration.
> > >
> > Ok can you state your specific goal with the custom partition so I have
> > more of an understanding of what you're trying to do?
> >
> > > Unfortunately, in my CustomPartition.doInit() method I attempt to test
> > > if the configuration that is returned from
> > > AbstractContextPartition.getConfiguration() is an instance of my new
> > > configuration, and if it is I want to use the new configuration
> > > settings to configure the custom partition. The implementation within
> > > DefaultContextPartitionNexus.addContextPartition() creates a new
> > > MutableContextPartitionConfiguration and copies the known values from
> > > the config that was passed into that method, thus by the time my code
> > > is called it is never an instance of my new configuration class.
> >
> > Ok I see.
> >
> > > Is this done to alleviate some known issue, or is it just an
> > > oversight. If it is an oversight, I can fix my local sandbox with a
> > > 'short sighted' implementation. If this is deliberately implemented
> > > this way, how are you supposed to use a new type of
> > > ContextPartitionConfiguration?
> >
> > In the server.xml you can set the bean class for the configuration
> > object's class to use your own configuration class. Here's where you'd
> > make the change:
> >
> > ...
> >
> > <bean id="examplePartitionConfiguration"
> > class="org.apache.ldap.server.configu
> > ration.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>
> >
> > ...
> >
> > So if your configuration class is com.example.MyParititionConfig then it
> >
> > would look like so:
> >
> > ...
> >
> > <bean id="examplePartitionConfiguration"
> > class="com.example.MyPartitionConfig">
> > <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>
> >
> > ...
> >
> > Give that a try and let us know how it goes.
> >
> > Cheers,
> > Alex
> >
> >
>
>
> --
> --------------------------------
> Lyndon Washington
> Snr. Software Engineer
> lwashington@novell.com
> 1.203.225.1815 (Shelton - CT)
> 1.781.464.8735 (Waltham - MA)
>
> Novell, Inc.
> Software for the Open Enterprise
> http://www.novell.com/open
>
--
--------------------------------
Lyndon Washington
Snr. Software Engineer
lwashington@novell.com
1.203.225.1815 (Shelton - CT)
1.781.464.8735 (Waltham - MA)
Novell, Inc.
Software for the Open Enterprise
http://www.novell.com/open
Re: Adding a Custom Partition Context
Posted by Lyndon Washington <lw...@novell.com>.
Done! http://issues.apache.org/jira/browse/DIREVE-301
On 11/2/05, Trustin Lee <tr...@gmail.com> wrote:
>
> There's a JIRA:
>
> issues.apache.org/jira/browse/DIREVE<http://issues.apache.org/jira/browse/DIREVE>
>
> Cheers,
> Trustin
>
> 2005/11/2, Lyndon Washington < lyndon.washington@gmail.com>:
> >
> > Okay, thanks for the confirmation. Is there a bugzilla system to track
> > this?
> >
> > Cheers,
> > -Lyndon-
> >
> > On 11/1/05, Trustin Lee < trustin@gmail.com> wrote:
> > >
> > > Hi Lyndon,
> > >
> > > 2005/11/2, Lyndon Washington <lyndon.washington@gmail.com >:
> > > >
> > > > Hi Alex,
> > > >
> > > > Thanks for the prompt reply.
> > > >
> > > > I have already tried that, and it fails to pass in my configuration
> > > > object because as I stated earlier, the "
> > > > DefaultContextPartitionNexus.addContextPartition() creates a new
> > > > MutableContextPartitionConfiguration" rather than using the configuration
> > > > that was instantiated based on the properties file.
> > > >
> > > > I have also tried altering one of the JUnit test cases and adding
> > > > the configuration to a Hashtable and passing that to a JNDI context
> > > > intitialization . . . no joy there either.
> > > >
> > > > Here is the offending code, IMHO, which shows that the config that
> > > > is passed in is not the one that is ultimately passed to '
> > > > partition.init()':
> > >
> > >
> > > Yes, you're right. ApacheDS internally copies it to
> > > MutableContextPartitionConfiguration before calling init(). For now you'll
> > > have to provide a getter/setter to your DirectoryPartition implementation.
> > >
> > > HTH,
> > > Trustin
> > > --
> > > what we call human nature is actually human habit
> > > --
> > > http://gleamynode.net/
> >
> >
> >
> >
> > --
> > --------------------------------
> > Lyndon Washington
> > Snr. Software Engineer
> > lwashington@novell.com
> > 1.203.225.1815 (Shelton - CT)
> > 1.781.464.8735 (Waltham - MA)
> >
> > Novell, Inc.
> > Software for the Open Enterprise
> > http://www.novell.com/open
> >
>
>
>
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
>
--
--------------------------------
Lyndon Washington
Snr. Software Engineer
lwashington@novell.com
1.203.225.1815 (Shelton - CT)
1.781.464.8735 (Waltham - MA)
Novell, Inc.
Software for the Open Enterprise
http://www.novell.com/open
Re: Adding a Custom Partition Context
Posted by Lyndon Washington <ly...@gmail.com>.
Done! http://issues.apache.org/jira/browse/DIREVE-301
On 11/2/05, Trustin Lee <tr...@gmail.com> wrote:
>
> There's a JIRA:
>
> issues.apache.org/jira/browse/DIREVE<http://issues.apache.org/jira/browse/DIREVE>
>
> Cheers,
> Trustin
>
> 2005/11/2, Lyndon Washington < lyndon.washington@gmail.com>:
> >
> > Okay, thanks for the confirmation. Is there a bugzilla system to track
> > this?
> >
> > Cheers,
> > -Lyndon-
> >
> > On 11/1/05, Trustin Lee < trustin@gmail.com> wrote:
> > >
> > > Hi Lyndon,
> > >
> > > 2005/11/2, Lyndon Washington <lyndon.washington@gmail.com >:
> > > >
> > > > Hi Alex,
> > > >
> > > > Thanks for the prompt reply.
> > > >
> > > > I have already tried that, and it fails to pass in my configuration
> > > > object because as I stated earlier, the "
> > > > DefaultContextPartitionNexus.addContextPartition() creates a new
> > > > MutableContextPartitionConfiguration" rather than using the configuration
> > > > that was instantiated based on the properties file.
> > > >
> > > > I have also tried altering one of the JUnit test cases and adding
> > > > the configuration to a Hashtable and passing that to a JNDI context
> > > > intitialization . . . no joy there either.
> > > >
> > > > Here is the offending code, IMHO, which shows that the config that
> > > > is passed in is not the one that is ultimately passed to '
> > > > partition.init()':
> > >
> > >
> > > Yes, you're right. ApacheDS internally copies it to
> > > MutableContextPartitionConfiguration before calling init(). For now you'll
> > > have to provide a getter/setter to your DirectoryPartition implementation.
> > >
> > > HTH,
> > > Trustin
> > > --
> > > what we call human nature is actually human habit
> > > --
> > > http://gleamynode.net/
> >
> >
> >
> >
> > --
> > --------------------------------
> > Lyndon Washington
> > Snr. Software Engineer
> > lwashington@novell.com
> > 1.203.225.1815 (Shelton - CT)
> > 1.781.464.8735 (Waltham - MA)
> >
> > Novell, Inc.
> > Software for the Open Enterprise
> > http://www.novell.com/open
> >
>
>
>
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
>
--
--------------------------------
Lyndon Washington
Snr. Software Engineer
lwashington@novell.com
1.203.225.1815 (Shelton - CT)
1.781.464.8735 (Waltham - MA)
Novell, Inc.
Software for the Open Enterprise
http://www.novell.com/open
Re: Adding a Custom Partition Context
Posted by Trustin Lee <tr...@gmail.com>.
There's a JIRA:
issues.apache.org/jira/browse/DIREVE<http://issues.apache.org/jira/browse/DIREVE>
Cheers,
Trustin
2005/11/2, Lyndon Washington <ly...@gmail.com>:
>
> Okay, thanks for the confirmation. Is there a bugzilla system to track
> this?
>
> Cheers,
> -Lyndon-
>
> On 11/1/05, Trustin Lee <tr...@gmail.com> wrote:
> >
> > Hi Lyndon,
> >
> > 2005/11/2, Lyndon Washington <lyndon.washington@gmail.com >:
> > >
> > > Hi Alex,
> > >
> > > Thanks for the prompt reply.
> > >
> > > I have already tried that, and it fails to pass in my configuration
> > > object because as I stated earlier, the "
> > > DefaultContextPartitionNexus.addContextPartition() creates a new
> > > MutableContextPartitionConfiguration" rather than using the configuration
> > > that was instantiated based on the properties file.
> > >
> > > I have also tried altering one of the JUnit test cases and adding the
> > > configuration to a Hashtable and passing that to a JNDI context
> > > intitialization . . . no joy there either.
> > >
> > > Here is the offending code, IMHO, which shows that the config that is
> > > passed in is not the one that is ultimately passed to 'partition.init
> > > ()':
> >
> >
> > Yes, you're right. ApacheDS internally copies it to
> > MutableContextPartitionConfiguration before calling init(). For now you'll
> > have to provide a getter/setter to your DirectoryPartition implementation.
> >
> > HTH,
> > Trustin
> > --
> > what we call human nature is actually human habit
> > --
> > http://gleamynode.net/
>
>
>
>
> --
> --------------------------------
> Lyndon Washington
> Snr. Software Engineer
> lwashington@novell.com
> 1.203.225.1815 (Shelton - CT)
> 1.781.464.8735 (Waltham - MA)
>
> Novell, Inc.
> Software for the Open Enterprise
> http://www.novell.com/open
>
--
what we call human nature is actually human habit
--
http://gleamynode.net/
Re: Adding a Custom Partition Context
Posted by Lyndon Washington <ly...@gmail.com>.
Okay, thanks for the confirmation. Is there a bugzilla system to track this?
Cheers,
-Lyndon-
On 11/1/05, Trustin Lee <tr...@gmail.com> wrote:
>
> Hi Lyndon,
>
> 2005/11/2, Lyndon Washington <ly...@gmail.com>:
> >
> > Hi Alex,
> >
> > Thanks for the prompt reply.
> >
> > I have already tried that, and it fails to pass in my configuration
> > object because as I stated earlier, the "
> > DefaultContextPartitionNexus.addContextPartition() creates a new
> > MutableContextPartitionConfiguration" rather than using the configuration
> > that was instantiated based on the properties file.
> >
> > I have also tried altering one of the JUnit test cases and adding the
> > configuration to a Hashtable and passing that to a JNDI context
> > intitialization . . . no joy there either.
> >
> > Here is the offending code, IMHO, which shows that the config that is
> > passed in is not the one that is ultimately passed to 'partition.init
> > ()':
>
>
> Yes, you're right. ApacheDS internally copies it to
> MutableContextPartitionConfiguration before calling init(). For now you'll
> have to provide a getter/setter to your DirectoryPartition implementation.
>
> HTH,
> Trustin
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
--
--------------------------------
Lyndon Washington
Snr. Software Engineer
lwashington@novell.com
1.203.225.1815 (Shelton - CT)
1.781.464.8735 (Waltham - MA)
Novell, Inc.
Software for the Open Enterprise
http://www.novell.com/open
Re: Adding a Custom Partition Context
Posted by Trustin Lee <tr...@gmail.com>.
Hi Lyndon,
2005/11/2, Lyndon Washington <ly...@gmail.com>:
>
> Hi Alex,
>
> Thanks for the prompt reply.
>
> I have already tried that, and it fails to pass in my configuration object
> because as I stated earlier, the "
> DefaultContextPartitionNexus.addContextPartition() creates a new
> MutableContextPartitionConfiguration" rather than using the configuration
> that was instantiated based on the properties file.
>
> I have also tried altering one of the JUnit test cases and adding the
> configuration to a Hashtable and passing that to a JNDI context
> intitialization . . . no joy there either.
>
> Here is the offending code, IMHO, which shows that the config that is
> passed in is not the one that is ultimately passed to 'partition.init()':
Yes, you're right. ApacheDS internally copies it to
MutableContextPartitionConfiguration before calling init(). For now you'll
have to provide a getter/setter to your DirectoryPartition implementation.
HTH,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
Re: Adding a Custom Partition Context
Posted by Lyndon Washington <ly...@gmail.com>.
Hi Alex,
Thanks for the prompt reply.
I have already tried that, and it fails to pass in my configuration object
because as I stated earlier, the "
DefaultContextPartitionNexus.addContextPartition() creates a new
MutableContextPartitionConfiguration" rather than using the configuration
that was instantiated based on the properties file.
I have also tried altering one of the JUnit test cases and adding the
configuration to a Hashtable and passing that to a JNDI context
intitialization . . . no joy there either.
Here is the offending code, IMHO, which shows that the config that is passed
in is not the one that is ultimately passed to 'partition.init()':
<snippet>
public synchronized void addContextPartition( ContextPartitionConfiguration
config ) throws NamingException
{
ContextPartition partition = config.getContextPartition();
// Turn on default indices
MutableContextPartitionConfiguration mcfg =
new MutableContextPartitionConfiguration();
mcfg.setName( config.getName() );
mcfg.setSuffix( config.getSuffix() );
mcfg.setContextEntry( config.getContextEntry() );
mcfg.setContextPartition( partition );
Set indexedAttrs = config.getIndexedAttributes();
indexedAttrs.add( Oid.ALIAS );
indexedAttrs.add( Oid.EXISTANCE );
indexedAttrs.add( Oid.HIERARCHY );
indexedAttrs.add( Oid.NDN );
indexedAttrs.add( Oid.ONEALIAS );
indexedAttrs.add( Oid.SUBALIAS );
indexedAttrs.add( Oid.UPDN );
mcfg.setIndexedAttributes( indexedAttrs );
String key = config.getSuffix();
if( partitions.containsKey( key ) )
{
throw new ConfigurationException( "Duplicate partition suffix: " + key );
}
partition.init( factoryCfg, mcfg );
partitions.put( partition.getSuffix( true ).toString(), partition );
Attribute namingContexts = rootDSE.get( NAMINGCTXS_ATTR );
namingContexts.add( partition.getSuffix( false ).toString() );
}
</snippet>
-Lyndon-
On 11/1/05, Alex Karasulu <ao...@bellsouth.net> wrote:
>
> Lyndon Washington wrote:
>
> ...
>
> > I have added my own CustomPartiton which extends
> > AbstractContextPartition. I have some configuration settings specific
> > to my partition, so I have also created a new
> > ContextPartitionConfiguration which extends
> > MutableContextPartitionConfiguration.
> >
> Ok can you state your specific goal with the custom partition so I have
> more of an understanding of what you're trying to do?
>
> > Unfortunately, in my CustomPartition.doInit() method I attempt to test
> > if the configuration that is returned from
> > AbstractContextPartition.getConfiguration() is an instance of my new
> > configuration, and if it is I want to use the new configuration
> > settings to configure the custom partition. The implementation within
> > DefaultContextPartitionNexus.addContextPartition() creates a new
> > MutableContextPartitionConfiguration and copies the known values from
> > the config that was passed into that method, thus by the time my code
> > is called it is never an instance of my new configuration class.
>
> Ok I see.
>
> > Is this done to alleviate some known issue, or is it just an
> > oversight. If it is an oversight, I can fix my local sandbox with a
> > 'short sighted' implementation. If this is deliberately implemented
> > this way, how are you supposed to use a new type of
> > ContextPartitionConfiguration?
>
> In the server.xml you can set the bean class for the configuration
> object's class to use your own configuration class. Here's where you'd
> make the change:
>
> ...
>
> <bean id="examplePartitionConfiguration"
> class="org.apache.ldap.server.configu
> ration.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>
>
> ...
>
> So if your configuration class is com.example.MyParititionConfig then it
> would look like so:
>
> ...
>
> <bean id="examplePartitionConfiguration"
> class="com.example.MyPartitionConfig">
> <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>
>
> ...
>
> Give that a try and let us know how it goes.
>
> Cheers,
> Alex
>
>
--
--------------------------------
Lyndon Washington
Snr. Software Engineer
lwashington@novell.com
1.203.225.1815 (Shelton - CT)
1.781.464.8735 (Waltham - MA)
Novell, Inc.
Software for the Open Enterprise
http://www.novell.com/open
Re: DirContext Search Error
Posted by Alex Karasulu <ao...@bellsouth.net>.
David Le Strat wrote:
>All,
>
>I am working on integration apacheDS with Jetspeed 2.
>I can create entries fine, but I am running into issue
>with the DirContext search.
>
>I obtain the following context using pretty much the
>default apacheds-server.xml
>
>env.put(Context.INITIAL_CONTEXT_FACTORY,
>"com.sun.jndi.ldap.LdapCtxFactory");
>env.put(Context.PROVIDER_URL,
>"ldap://localhost:10389/");
>env.put(Context.SECURITY_PRINCIPAL,
>"uid=admin,ou=system");
>env.put(Context.SECURITY_CREDENTIALS, rootPassword);
>env.put(Context.SECURITY_AUTHENTICATION, "simple");
>ctx = new InitialLdapContext(env, null);
>
>
>
Ok if you're embedding why are you going through the protocol with the
SUN LDAP Provider to operate on ApacheDS entries? Use the
CoreContextFactory instead that comes with apacheds to get a handle on
it. That way you don't have to waste cycles going through the network
stack.
>As you can see the default setting uses
>com.sun.jndi.ldap.LdapCtxFactory.
>
>I want to run the following search context query:
>
>SearchControls controls = new SearchControls();
>controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
>controls.setReturningObjFlag(true);
>
>NamingEnumeration searchResults = ((DirContext)
>ctx).search("", "(&(uid=1269495866)
>(objectclass=jetspeed-2-user))", controls );
>
>When doing so, I get the following error:
>
>org.apache.jetspeed.security.SecurityException:
>javax.naming.NamingException: [LDAP: error code 36 -
>failed on search operation]; remaining name ''
>
>org.apache.jetspeed.security.SecurityException: Caused
>by: javax.naming.NamingException: [LDAP: error code 36
>- failed on search operation]; remaining name ''
> at
>com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:2964)
> at
>com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2934)
> at
>com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2740)
> at
>com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1811)
> at
>com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1734)
> at
>com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368)
> at
>com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:328)
> at
>com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:313)
> at
>javax.naming.directory.InitialDirContext.search(InitialDirContext.java:238)
> at
>org.apache.jetspeed.security.spi.impl.ldap.AbstractLdapDao.searchByWildcardedUid(AbstractLdapDao.java:275)
> at
>org.apache.jetspeed.security.spi.impl.ldap.AbstractLdapDao.lookupByUid(AbstractLdapDao.java:210)
> ... 13 more
>
>
>
David this is internal to the SUN JNDI Provider. I don't have a clue
why it would be failing. I'd try the search on another LDAP server to
see the behavoir. If the response is the same then you have a config
issue with the SUN provider. If not then we can start looking at
ethereal dumps to see what's going on. Might be the SUN provider is
getting an error code it cannot map to a JNDI exception, however it
usually defaults to a general NamingException if that's the case.
Alex
DirContext Search Error
Posted by David Le Strat <dl...@yahoo.com>.
All,
I am working on integration apacheDS with Jetspeed 2.
I can create entries fine, but I am running into issue
with the DirContext search.
I obtain the following context using pretty much the
default apacheds-server.xml
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL,
"ldap://localhost:10389/");
env.put(Context.SECURITY_PRINCIPAL,
"uid=admin,ou=system");
env.put(Context.SECURITY_CREDENTIALS, rootPassword);
env.put(Context.SECURITY_AUTHENTICATION, "simple");
ctx = new InitialLdapContext(env, null);
As you can see the default setting uses
com.sun.jndi.ldap.LdapCtxFactory.
I want to run the following search context query:
SearchControls controls = new SearchControls();
controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
controls.setReturningObjFlag(true);
NamingEnumeration searchResults = ((DirContext)
ctx).search("", "(&(uid=1269495866)
(objectclass=jetspeed-2-user))", controls );
When doing so, I get the following error:
org.apache.jetspeed.security.SecurityException:
javax.naming.NamingException: [LDAP: error code 36 -
failed on search operation]; remaining name ''
org.apache.jetspeed.security.SecurityException: Caused
by: javax.naming.NamingException: [LDAP: error code 36
- failed on search operation]; remaining name ''
at
com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:2964)
at
com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2934)
at
com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2740)
at
com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1811)
at
com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1734)
at
com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368)
at
com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:328)
at
com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:313)
at
javax.naming.directory.InitialDirContext.search(InitialDirContext.java:238)
at
org.apache.jetspeed.security.spi.impl.ldap.AbstractLdapDao.searchByWildcardedUid(AbstractLdapDao.java:275)
at
org.apache.jetspeed.security.spi.impl.ldap.AbstractLdapDao.lookupByUid(AbstractLdapDao.java:210)
... 13 more
I would appreciate if anyone had any pointer on what I
am missing here.
Thank you.
Regards,
David Le Strat
________________________
David Le Strat
Blogging @ http://dlsthoughts.blogspot.com
__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com
Re: Adding a schema extension
Posted by Emmanuel Lecharny <el...@apache.org>.
On Tue, 2005-11-01 at 16:10 -0800, David Le Strat wrote:
> All,
David,
> I apologize for posting a fairly basic question on the
> dev list. I could not find the user list.
Don't be sorry, at this moment, we don't have any user list : we don't
have many users, so welcome !!!
> I am working on integrating apacheDS with Jetspeed2
> security. I need to create a schema extension. I
> have generated my schema (as a jar) using the
> directory maven plugin
I bet that you have used maven goals :
Goal
Description
directory:generate
Generates class files for OpenLDAP
schemas.
directory:init
Finds the required parameters needed
for the goals of the plugin.
directory:prepare-filesystem
Creates source output directories
used to deposite schema files that
are generated.
directory:schema
Top level schema generating function
that uses other goals to coordinate
generation.
> and I added my new schema to my
> server.xml as followed:
>
> <property name="bootstrapSchemas">
> <set>
> Apache DS entries
> ...
> <bean
> class="org.apache.jetspeed.security.ldap.JetspeedSchema"/>
> </set>
> </property>
>
> I start apacheDS with the new jar file in its
> classpath. The new schema does not seem to get picked
> up. I am missing a step.
Here is an excerpt to the doc that will be soon available on the site :
"How to Integrate Plugin Into Your Own Projects
You want to use the plugin to generate classes for your own schema.
Here's a step wise process you can follow to do that using maven:
1. Place your schema files (i.e. foo.schema) with the schema
extension into ${basedir}/src/main/schema. If you opt to store
it in another location you must override the
maven.ldap.server.schema.dir property in your project.properties
file. For each schema file add the file base name to the
maven.ldap.server.schemas property which is a space separated
list.
2. The plugin will by default generate java files within the
${basedir}/target/schema directory. If you would like to
generate code elsewhere you must override the
maven.ldap.server.schema.target.dir property in your
project.properties file.
3. By default the plugin generates code in a server schema package:
org.apache.ldap.server.schema.bootstrap. If you want generated
code for a schema to be put into a package other than this, then
you're going to need to set the package property for the schema.
The package property key is composed of the following base,
maven.ldap.server.schema.package. with the name of the schema
(without the extension) appended to it. So for schema file
foo.schema the following property key would be used:
maven.ldap.server.schema.package.foo where foo is the schema
name.
4. Using the same pattern above for all schema specific properties
you can set other per schema properties as well. One of these
properties is the dependency list for a schema. Schemas can
obviously depend on others. The schema dependency list is a
comma separated list of other schema names. These schemas need
not be present in your project to generate the code for your
schema. The dependent schema classes must however be present
within the server at start up time in order to load and use your
schema. At the end we list the default schemas already packaged
into the server's jar. You can use any one of these schemas as
dependencies needed by your schema and not worry about their
presence. The property key base for the schema dependency list
is maven.ldap.server.schema.deps. and for a foo.schema file the
full key would be maven.ldap.server.schema.deps.foo
5. Each schema has an owner associated with it. If you want the
owner to be anything other than the server's super user you may
want to set the owner property for the schema in your
project.properties file. The property key base for the schema is
maven.ldap.server.schema.owner. so don't forget to append the
schema name to it.
Once setup you can invoke maven to generate the schema sources like so:
[akarasulu@newton dib]$ maven directory:schema
__ __
| \/ |__ _Apache__ ___
| |\/| / _` \ V / -_) ' \ ~ intelligent projects ~
|_| |___,_|_/___|_||_| v. 1.0.2
Attempting to download ldap-common-0.8.0-SNAPSHOT.jar.
Attempting to download apacheds-shared-0.8.0-SNAPSHOT.jar.
Attempting to download apacheds-protocol-0.8.0-SNAPSHOT.jar.
Attempting to download snickers-codec-0.2.0-SNAPSHOT.jar.
Attempting to download ldap-snickers-provider-0.8.0-SNAPSHOT.jar.
Attempting to download snickers-ber-0.2.0-SNAPSHOT.jar.
Attempting to download seda-0.2.0-SNAPSHOT.jar.
Attempting to download maven-directory-plugin-0.8.0-SNAPSHOT.jar.
Attempting to download ldap-common-0.8.0-SNAPSHOT.jar.
Attempting to download apacheds-shared-0.8.0-SNAPSHOT.jar.
build:start:
directory:schema:
directory:init:
directory:prepare-filesystem:
directory:generate:
[echo] Generated schema producer classes for autofs.schema
[echo] Generated schema producer classes for core.schema
[echo] Generated schema producer classes for cosine.schema
[echo] Generated schema producer classes for corba.schema
[echo] Generated schema producer classes for eve.schema
[echo] Generated schema producer classes for inetorgperson.schema
[echo] Generated schema producer classes for java.schema
[echo] Generated schema producer classes for krb5kdc.schema
[echo] Generated schema producer classes for nis.schema
[echo] Generated schema producer classes for system.schema
[echo] Generated schema producer classes for scheduleworld.schema
[touch] Creating /home/akarasulu/projects/directory/server/trunk/core/target/schema/.flagfile
BUILD SUCCESSFUL
Total time: 28 seconds
Finished at: Tue Dec 14 15:26:26 EST 2004
The example above is from the server's core project. If you would like
to look at how to use this plugin best the server core
project.properties file here is perhaps the best place to look. Also
from the output above you can see the schema files that are used and
packaged into the server by default. This may however change in the
future to restrict the set.
WARNING: As a last bit of advice make note that the plugin may be
sensitive to case for keywords in the OpenLDAP file. For example the
prefix before an objectClass or an attributeType must be in all
lowercase. However words like MUST, and MAY and SUP should all be in
uppercase. So if plugin bombs just check out where this happens and play
with the case. Another thing to watch out for is the order of terms.
This we follow the RFC for which is pretty much the same as the OpenLDAP
format minus the objectclass and attributetype prefixes to the
descriptions. We figure the OpenLDAP parser is less complex if the
prefixes are there (where the parser is told if the description is an
objectclass or attributetype and does not have to figure this out).
However I have encountered schemas whose formats do not comply with
standards in with respect to the order of description fields and had to
edit the files. This issue did not occur when the files were from the
OpenLDAP Foundation which means they do it right but overlook schema
objects that are not correctly formated." (Thanks Alex for the doc ;)
I hope that it will help you to embed ApacheDS in JetSpeed. However,
feel free to contact us if you hit a wall.
>
> Regards,
>
> David Le Strat
-- Emmanuel
PS : Cool blog, David.
PS2 : Et désolé pour l'anglais défaillant ... Pourtant, je fais des
efforts ;)
Adding a schema extension
Posted by David Le Strat <dl...@yahoo.com>.
All,
I apologize for posting a fairly basic question on the
dev list. I could not find the user list.
I am working on integrating apacheDS with Jetspeed2
security. I need to create a schema extension. I
have generated my schema (as a jar) using the
directory maven plugin and I added my new schema to my
server.xml as followed:
<property name="bootstrapSchemas">
<set>
Apache DS entries
...
<bean
class="org.apache.jetspeed.security.ldap.JetspeedSchema"/>
</set>
</property>
I start apacheDS with the new jar file in its
classpath. The new schema does not seem to get picked
up. I am missing a step.
Regards,
David Le Strat
________________________
David Le Strat
Blogging @ http://dlsthoughts.blogspot.com
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
Re: Adding a Custom Partition Context
Posted by Alex Karasulu <ao...@bellsouth.net>.
Lyndon Washington wrote:
...
> I have added my own CustomPartiton which extends
> AbstractContextPartition. I have some configuration settings specific
> to my partition, so I have also created a new
> ContextPartitionConfiguration which extends
> MutableContextPartitionConfiguration.
>
Ok can you state your specific goal with the custom partition so I have
more of an understanding of what you're trying to do?
> Unfortunately, in my CustomPartition.doInit() method I attempt to test
> if the configuration that is returned from
> AbstractContextPartition.getConfiguration() is an instance of my new
> configuration, and if it is I want to use the new configuration
> settings to configure the custom partition. The implementation within
> DefaultContextPartitionNexus.addContextPartition() creates a new
> MutableContextPartitionConfiguration and copies the known values from
> the config that was passed into that method, thus by the time my code
> is called it is never an instance of my new configuration class.
Ok I see.
> Is this done to alleviate some known issue, or is it just an
> oversight. If it is an oversight, I can fix my local sandbox with a
> 'short sighted' implementation. If this is deliberately implemented
> this way, how are you supposed to use a new type of
> ContextPartitionConfiguration?
In the server.xml you can set the bean class for the configuration
object's class to use your own configuration class. Here's where you'd
make the change:
...
<bean id="examplePartitionConfiguration"
class="org.apache.ldap.server.configu
ration.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>
...
So if your configuration class is com.example.MyParititionConfig then it
would look like so:
...
<bean id="examplePartitionConfiguration"
class="com.example.MyPartitionConfig">
<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>
...
Give that a try and let us know how it goes.
Cheers,
Alex