You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Jacob Barrett <Ja...@attachmatewrq.com> on 2005/09/21 00:38:58 UTC

In process access to directory.

What is the correct method for getting the JNDI context of the directory
from "in process" without going through LDAP?  I figured it would just
be:

Properties env = new Properties();
env.setProperty(Context.INITIAL_CONTEXT_FACTORY,
CoreContextFactory.class.getName());
new InitialDirContext(env);

The source behind this (AbstractContextFactory) though expects one of
the Configuration objects in the env, and from what I can tell there
isn't one that just locates a directory by it's instance id.

Am I on the correct track?  Do I just need to patch the
AbstractContextFactory to look for the instance id as a env property if
no config property is found?  Is there a better way to get the context
internally?

My end game here is to be able to grab the context as different users.
I don't want to have to do it through the loopback address via LDAP.  Is
this the correct way to do this?

=Jake

Re: In process access to directory.

Posted by Trustin Lee <tr...@gmail.com>.
Hi,

I apologize for my late response first of all.

2005/9/23, Jacob S. Barrett <ja...@attachmate.com>:
>
> Trustin Lee wrote:
> > 2005/9/21, Jacob Barrett <JacobBa@attachmatewrq.com
> > <ma...@attachmatewrq.com>>:
> >
> > The source behind this (AbstractContextFactory) though expects one of
> > the Configuration objects in the env, and from what I can tell there
> > isn't one that just locates a directory by it's instance id.
> >
> >
> > You can simply use StartupConfiguration because ApacheDS will ignore the
> > request if the service is already started up. It will also return a
> > JNDI context with an appropriate running user as you specified in your
> > StartupConfiguration.
>
> Yeah, but since I want others that are not familiar to the ApacheDS to
> be able to access the context that I have already setup for them in
> process I was hoping for something a little more simple.
>
> I have started making a few alterations. I added an env value
> "org.apache.ldap.server.jndi.service.instance" to specify the env you
> want. If that value is not set and there is no cfg set then it will try
> to load the "default" instance. This is a short term fix in my mind
> though. When I get a bit more time I would like to use the provider URL
> for this since that is more appropriate. Something along the lines of
> <instance>/<basedn> or <instance>:<basedn>. Since technically a URL
> must have a scheme followed by a colon the second option fits that
> format, it is just odd to have arbitrarily named schemes. Regardless of
> format the AbstractContextFactory would strip out the instance from the
> URL and and pass the remainder of the URL up to the context like it does
> now.


Your idea on letting users provide instanceId in an url is great. I've filed
this issue to JIRA:

http://issues.apache.org/jira/browse/DIREVE-270

Thanks,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/

Re: In process access to directory.

Posted by "Jacob S. Barrett" <ja...@attachmate.com>.
Trustin Lee wrote:
> 2005/9/21, Jacob Barrett <JacobBa@attachmatewrq.com 
> <ma...@attachmatewrq.com>>:
> 
>     The source behind this (AbstractContextFactory) though expects one of
>     the Configuration objects in the env, and from what I can tell there
>     isn't one that just locates a directory by it's instance id.
> 
> 
> You can simply use StartupConfiguration because ApacheDS will ignore the 
> request if the service is already started up.  It will also return a 
> JNDI context with an appropriate running user as you specified in your 
> StartupConfiguration.

Yeah, but since I want others that are not familiar to the ApacheDS to 
be able to access the context that I have already setup for them in 
process I was hoping for something a little more simple.

I have started making a few alterations.  I added an env value 
"org.apache.ldap.server.jndi.service.instance" to specify the env you 
want.  If that value is not set and there is no cfg set then it will try 
to load the "default" instance.  This is a short term fix in my mind 
though.  When I get a bit more time I would like to use the provider URL 
for this since that is more appropriate.  Something along the lines of 
<instance>/<basedn> or <instance>:<basedn>.  Since technically a URL 
must have a scheme followed by a colon the second option fits that 
format, it is just odd to have arbitrarily named schemes.  Regardless of 
format the AbstractContextFactory would strip out the instance from the 
URL and and pass the remainder of the URL up to the context like it does 
now.

What are your thoughts on this matter?

Re: In process access to directory.

Posted by Trustin Lee <tr...@gmail.com>.
Hi Jacob,

2005/9/21, Jacob Barrett <Ja...@attachmatewrq.com>:
>
> The source behind this (AbstractContextFactory) though expects one of
> the Configuration objects in the env, and from what I can tell there
> isn't one that just locates a directory by it's instance id.


You can simply use StartupConfiguration because ApacheDS will ignore the
request if the service is already started up. It will also return a JNDI
context with an appropriate running user as you specified in your
StartupConfiguration.

Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/