use of com.unboundid.ldif.LDIFAddChangeRecord in project gocd by gocd.
the class InMemoryLdapServerForTests method addOrganizationalUnit.
public LDIFRecord addOrganizationalUnit(String nameOfOU, String dnOfOU) throws LDAPException {
LDIFAddChangeRecord record = new LDIFAddChangeRecord(dnOfOU, new Attribute("objectClass", "top", "organizationalUnit"), new Attribute("ou", nameOfOU));
record.processChange(server);
return record;
}
use of com.unboundid.ldif.LDIFAddChangeRecord in project gocd by gocd.
the class InMemoryLdapServerForTests method startServer.
private InMemoryDirectoryServer startServer(int port, String baseDn, String bindDn, String bindPassword) throws LDAPException, BindException {
InMemoryListenerConfig listenerConfig = InMemoryListenerConfig.createLDAPConfig("default", port);
InMemoryDirectoryServerConfig serverConfig = new InMemoryDirectoryServerConfig(new DN(baseDn));
/* Ignore schema so that it does not complain that some attributes (like sAMAccountName) are not valid. */
serverConfig.setSchema(null);
serverConfig.setListenerConfigs(listenerConfig);
serverConfig.addAdditionalBindCredentials(bindDn, bindPassword);
InMemoryDirectoryServer server = new InMemoryDirectoryServer(serverConfig);
try {
server.startListening();
} catch (LDAPException e) {
throw new RuntimeException(e);
}
new LDIFAddChangeRecord(baseDn, new Attribute("objectClass", "domain", "top")).processChange(server);
return server;
}
Aggregations