You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Ole Ersoy <ol...@gmail.com> on 2007/04/11 05:15:08 UTC

[JNDI] Navigating the DIT

Hey Guys,

Got a question.

Before writing a DataGraph we need to make sure the the 
InitialDirectoryContext exists.

Suppose the base DN is:

DN: cn=Accounts, cn=users, cn=example, ou=com

And previous another model had this as its base DN

DN: cn=Authorization, cn=users, cn=example, ou=com

However the DAS does not know that the context
DN: cn=users, cn=example, ou=com

exists.

So it wants to start with the initial context
DN: ou=com

Then it wants to check if the subcontext
cn=example exists, and jump to it if it does.  Otherwise
it will just create it, and the returned context will
be the right one.

So I have some code like this:

public static DirContext createSubcontext(DirContext dirContext, String 
subContext)
     {
         try
         {
             dirContext = dirContext.createSubcontext( subContext );
         }
         catch ( NamingException e )
         {
             //change to the subcontext?
         }
         return dirContext;
     }

So this tries to create the subcontext and if an
exception thrown it wants to change to the
subcontext that it tried to create.

I looked through the DirContext javadocs did not see
a way to do this.  Seems like it should be really easy
though.

Any ideas?

Thanks,
- Ole