I start an LDAP test-server with the following code:
public class ADTestContainer implements QuarkusTestResourceLifecycleManager {
public static final Logger logger = LoggerFactory.getLogger(ADTestContainer.class);
private LDAPConnection ldapConnection;
private InMemoryDirectoryServer ds;
@Override
public Map<String, String> start() {
try {
logger.info("Starting application LDAP test container");
InMemoryDirectoryServerConfig config =
new InMemoryDirectoryServerConfig("dc=nte,dc=local");
config.addAdditionalBindCredentials("cn=Directory Manager", "password");
// Create the directory server instance, populate it with data from the
// "test-data.ldif" file, and start listening for client connections.
ds = new InMemoryDirectoryServer(config);
logger.info(ds.getBaseDNs().toString()); //[dc=local,dc=nte]
ds.importFromLDIF(true, "target/test-classes/data.ldif");
ds.startListening();
// Get a client connection to the server and use it to perform various
// operations.
ldapConnection = ds.getConnection();
return Map.of(
"ldap.user", "cn=Directory Manager",
"ldap.password", "password",
"ldap.url", "ldap://" + ldapConnection.getConnectedAddress() + ":" + ds.getListenPort(),
"ldap.realm", "test"
);
} catch (Exception e) {
logger.error("Failed to setup application MongoDb test container", e);
try {
throw e;
} catch (LDAPException ex) {
ex.printStackTrace();
}
}
return null;
}
@Override
public void stop() {
if (nonNull(ldapConnection)) {
logger.info("Stopping Ldap test container");
ldapConnection.close();
ds.shutDown(true);
}
}
}
I am trying to add data with the following file:
dn: ou=NTEou,dc=nte,dc=local objectClass: organizationalUnit ou: NTEou
But it fails with the following error:
Unable to add entry 'ou=NTEou,dc=nte,dc=local' because its parent entry 'dc=nte,dc=local' does not exist in the server.
I start an LDAP test-server with the following code:
I am trying to add data with the following file:
dn: ou=NTEou,dc=nte,dc=local objectClass: organizationalUnit ou: NTEou
But it fails with the following error: Unable to add entry 'ou=NTEou,dc=nte,dc=local' because its parent entry 'dc=nte,dc=local' does not exist in the server.