I am trying to duplicate the LDAP mockup / schema from the field the application should be running to - and I am trying to recreate + test it using an automated test with the Embedded LDAP UnboundID server.
The situation he has to deal with is that the userOf property of the user schema, such as Active Directory, has ... but I'm not quite sure how to add the user class to this ldap in memory.
1) Is it possible? 2) Is there a better strategy? 3) And what exactly should I do? I am new to LDAP.
Below is my broken code.
Thank you Mike Cohout
public class TestOpenLdap2
{
private InMemoryDirectoryServer server;
@Before
public void start() throws Exception
{
InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=com");
config.addAdditionalBindCredentials("cn=admin,ou=People,dc=example,dc=com", "cred");
InMemoryListenerConfig listenerConfig = new InMemoryListenerConfig("test", null, 33390, null, null, null);
config.setListenerConfigs(listenerConfig);
server = new InMemoryDirectoryServer(config);
server.startListening();
}
@Test
public void testMemberOf() throws Exception
{
addEntry("dn: dc=com", "objectClass: top", "objectClass: domain", "dc: com");
ObjectClassDefinition oc = new ObjectClassDefinition("10.19.19.78", new String[]{"user"}, "", false, new String[]{"TOP"},
ObjectClassType.STRUCTURAL, new String[]{"memberOf"},
new String[]{}, new HashMap());
addEntry("dn: cn=schema2,dc=com", "objectClass: top", "objectClass: ldapSubEntry", "objectClass: subschema", "cn: schema2",
"objectClasses: " + oc.toString());
addEntry("dn: dc=people,dc=com", "objectClass: top", "objectClass: domain", "dc: people");
addEntry("dn: dc=groups,dc=com", "objectClass: top", "objectClass: domain", "dc: groups");
addEntry("dn: cn=test-group,dc=groups,dc=com", "objectClass: groupOfUniqueNames", "cn: test group");
addEntry("dn: cn=Testy Tester,dc=people,dc=com", "objectClass: Person", "objectClass: user", "objectClass: organizationalPerson", "sn: Tester", "cn: Testy Tester", "memberOf: cn=test-group,dc=groups,dc=com");
}
public void addEntry(String... args) throws LDIFException, LDAPException
{
LDAPResult result = server.add(args);
assert (result.getResultCode().intValue() == 0);
System.out.println("added entry:" + Arrays.asList(args));
}