Search in sources :

Example 1 with LDIFAddChangeRecord

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;
}
Also used : Attribute(com.unboundid.ldap.sdk.Attribute) LDIFAddChangeRecord(com.unboundid.ldif.LDIFAddChangeRecord)

Example 2 with LDIFAddChangeRecord

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;
}
Also used : LDAPException(com.unboundid.ldap.sdk.LDAPException) Attribute(com.unboundid.ldap.sdk.Attribute) InMemoryDirectoryServer(com.unboundid.ldap.listener.InMemoryDirectoryServer) LDIFAddChangeRecord(com.unboundid.ldif.LDIFAddChangeRecord) InMemoryDirectoryServerConfig(com.unboundid.ldap.listener.InMemoryDirectoryServerConfig) InMemoryListenerConfig(com.unboundid.ldap.listener.InMemoryListenerConfig) DN(com.unboundid.ldap.sdk.DN)

Aggregations

Attribute (com.unboundid.ldap.sdk.Attribute)2 LDIFAddChangeRecord (com.unboundid.ldif.LDIFAddChangeRecord)2 InMemoryDirectoryServer (com.unboundid.ldap.listener.InMemoryDirectoryServer)1 InMemoryDirectoryServerConfig (com.unboundid.ldap.listener.InMemoryDirectoryServerConfig)1 InMemoryListenerConfig (com.unboundid.ldap.listener.InMemoryListenerConfig)1 DN (com.unboundid.ldap.sdk.DN)1 LDAPException (com.unboundid.ldap.sdk.LDAPException)1