directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Carlson <>
Subject Re: ApplyLdifs
Date Fri, 16 Sep 2011 22:57:30 GMT
Thanks so much Stefan for taking the time to make that example.  I just didn't notice the formatting
change in the example code I was looking at.

Is there an example of creating a small hierarchy?  I've tried something like this but got
an error saying there was no partition for dc=example,dc=com

"dn: dc=example,dc=com",
"objectClass: dcObject",
"dn: ou=users,dc=example,dc=com",
"objectClass: organizationalUnit",
"ou: users\n",
"dn: cn=jon,ou=users,dc=example,dc=com",
"objectClass: person",
"cn: jon",
"sn: Carlson"

Also, is there an example of doing a lookup on a directory created this way using an InitialContext?
 The LDAP client framework that I am testing uses this method of lookup so it needs to support

// Create a environment container
Hashtable<Object, Object> env = new Hashtable<Object, Object>();
env.put(Context.PROVIDER_URL, "ldap://localhost:1024");
env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
env.put(Context.SECURITY_CREDENTIALS, "secret");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
InitialContext initialContext = new InitialContext(env);
DirContext appRoot = (DirContext) initialContext.lookup("");
SearchControls controls = new SearchControls();
NamingEnumeration<SearchResult> results ="", "(cn=jon)", controls);

Thanks so much for your help.  Have a great weekend.

- Jon

On Sep 16, 2011, at 5:07 PM, Stefan Seelmann wrote:

Please try to concat the LDIF with commas like this:

       "dn: cn=jon4,ou=system",
       "objectClass: person",
       "cn: jon4",
       "sn: Carlson"

Here is a full working example:

Kind Regards,

On Fri, Sep 16, 2011 at 8:49 PM, Jonathan Carlson <<>>
I'm hoping there is an easy answer to this...

When I specify @ApplyLdifs on the test class it *always* tells me that the dn exists already,
even if it is the first time I've run it.

"dn: cn=jon4,ou=system\n" +
"objectClass: person\n" +
"cn: jon4\n" +
"sn: Carlson\n"
allowAnonymousAccess = true,
transports = { @CreateTransport(protocol = "LDAP") }) ERR_250 cn=jon4,ou=system
already exists!

Yet, when I move the @ApplyLdifs to a method, the method doesn't get run by jUnit.

I'm using the Apache DS version 1.5.7 libraries...


jon carlson   |  codefortytwo software
1 Main St SE, #400     |   Minneapolis, MN 55414
Office: 612.333.4242  |   web:<>

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message