directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Karasulu <>
Subject Re: Configure (Eve) server from properties file.
Date Wed, 02 Mar 2005 04:09:59 GMT
Robert r. Sanders wrote:

> I'd like to use the JNDI server so that I can create and run JUnit 
> tests of JNDI/LDAP functionality.  To that end I'm trying to figure 
> out the easiest way to configure a server instance; it looked like 
> properties files would be a decent way (at least better than 
> programmatically creating a bunch of JNDI Attribute objects); but I 
> don' t know how to get the server to load a properties file - this is 
> what I have so far (using properties file contents from documentation 
> example):
When running it via command line it can have prop file arg but you don't 
need that.  Looks like you're doing it right below.

> Properties env = new Properties();
> FileInputStream in = new 
> FileInputStream("sandbox/src/test/");
> env.load(in);
> env.put( Context.PROVIDER_URL, "ou=system" );
> env.put( Context.INITIAL_CONTEXT_FACTORY, 
> "org.apache.ldap.server.jndi.ServerContextFactory" );
> env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
> env.put( Context.SECURITY_CREDENTIALS, "secret" );
Looks good to me.  Is this not working?

> DirContext ctx = new InitialDirContext( env );
> Once I have the DirContext I have just been using code from the JNDI 
> tutorial to see what's there:
> NamingEnumeration list = ctx.list("");
> while (list.hasMore()) {
>    NameClassPair nc = (NameClassPair);
>    System.out.println( nc );
> }

You should see the listing of some entries.  Let me know if you have a 
problem.  You approach looks good.


View raw message