Search in sources :

Example 11 with LdapNetworkConnection

use of org.apache.directory.ldap.client.api.LdapNetworkConnection in project midpoint by Evolveum.

the class AbstractLdapTest method deleteLdapEntry.

protected void deleteLdapEntry(String dn) throws LdapException, IOException {
    LdapNetworkConnection connection = ldapConnect();
    connection.delete(dn);
    display("Deleted LDAP entry: " + dn);
    ldapDisconnect(connection);
}
Also used : LdapNetworkConnection(org.apache.directory.ldap.client.api.LdapNetworkConnection)

Example 12 with LdapNetworkConnection

use of org.apache.directory.ldap.client.api.LdapNetworkConnection in project midpoint by Evolveum.

the class AbstractLdapTest method cleanupDelete.

/**
	 * Silent delete. Used to clean up after previous test runs.
	 */
protected void cleanupDelete(UserLdapConnectionConfig config, String dn) throws LdapException, IOException, CursorException {
    LdapNetworkConnection connection = ldapConnect(config);
    Entry entry = getLdapEntry(connection, dn);
    if (entry != null) {
        connection.delete(dn);
        display("Cleaning up LDAP entry: " + dn);
    }
    ldapDisconnect(connection);
}
Also used : Entry(org.apache.directory.api.ldap.model.entry.Entry) SearchResultEntry(org.apache.directory.api.ldap.model.message.SearchResultEntry) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) LdapNetworkConnection(org.apache.directory.ldap.client.api.LdapNetworkConnection)

Example 13 with LdapNetworkConnection

use of org.apache.directory.ldap.client.api.LdapNetworkConnection in project midpoint by Evolveum.

the class AbstractLdapSynchronizationTest method test817RenameAccount.

@Test
public void test817RenameAccount() throws Exception {
    final String TEST_NAME = "test817RenameAccount";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    long tsStart = System.currentTimeMillis();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    LdapNetworkConnection connection = ldapConnect();
    ModifyDnRequest modDnRequest = new ModifyDnRequestImpl();
    modDnRequest.setName(new Dn(toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN)));
    modDnRequest.setNewRdn(toAccountRdn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN));
    modDnRequest.setDeleteOldRdn(true);
    ModifyDnResponse modDnResponse = connection.modifyDn(modDnRequest);
    display("Modified " + toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN) + " -> " + toAccountRdn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN) + ": " + modDnResponse);
    doAdditionalRenameModifications(connection);
    ldapDisconnect(connection);
    waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    long tsEnd = System.currentTimeMillis();
    PrismObject<UserType> user = findUserByUsername(ACCOUNT_HTM_UID);
    assertNotNull("No user " + ACCOUNT_HTM_UID + " created", user);
    assertUser(user, user.getOid(), ACCOUNT_HTM_UID, getAccountHtmCnAfterRename(), ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN_MODIFIED);
    assertNull("User " + ACCOUNT_HT_UID + " still exist", findUserByUsername(ACCOUNT_HT_UID));
    assertStepSyncToken(getSyncTaskOid(), 4, tsStart, tsEnd);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Dn(org.apache.directory.api.ldap.model.name.Dn) LdapNetworkConnection(org.apache.directory.ldap.client.api.LdapNetworkConnection) ModifyDnRequest(org.apache.directory.api.ldap.model.message.ModifyDnRequest) ModifyDnResponse(org.apache.directory.api.ldap.model.message.ModifyDnResponse) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ModifyDnRequestImpl(org.apache.directory.api.ldap.model.message.ModifyDnRequestImpl) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 14 with LdapNetworkConnection

use of org.apache.directory.ldap.client.api.LdapNetworkConnection in project midpoint by Evolveum.

the class AbstractLdapSynchronizationTest method test802ModifyAccountHt.

// Do not change cn here. This triggers rename in the AD case.
@Test
public void test802ModifyAccountHt() throws Exception {
    final String TEST_NAME = "test802ModifyAccountHt";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    long tsStart = System.currentTimeMillis();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    LdapNetworkConnection connection = ldapConnect();
    Modification modCn = new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, "sn", ACCOUNT_HT_SN_MODIFIED);
    connection.modify(toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN), modCn);
    ldapDisconnect(connection);
    waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    long tsEnd = System.currentTimeMillis();
    PrismObject<UserType> user = findUserByUsername(ACCOUNT_HT_UID);
    assertNotNull("No user " + ACCOUNT_HT_UID + " created", user);
    assertUser(user, user.getOid(), ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN_MODIFIED);
    assertStepSyncToken(getSyncTaskOid(), 2, tsStart, tsEnd);
}
Also used : DefaultModification(org.apache.directory.api.ldap.model.entry.DefaultModification) Modification(org.apache.directory.api.ldap.model.entry.Modification) Task(com.evolveum.midpoint.task.api.Task) DefaultModification(org.apache.directory.api.ldap.model.entry.DefaultModification) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) LdapNetworkConnection(org.apache.directory.ldap.client.api.LdapNetworkConnection) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 15 with LdapNetworkConnection

use of org.apache.directory.ldap.client.api.LdapNetworkConnection in project midpoint by Evolveum.

the class AbstractLdapTest method assertNoLdapAccount.

protected void assertNoLdapAccount(String uid) throws LdapException, IOException, CursorException {
    LdapNetworkConnection connection = ldapConnect();
    List<Entry> entries = ldapSearch(connection, "(uid=" + uid + ")");
    ldapDisconnect(connection);
    assertEquals("Unexpected number of entries for uid=" + uid + ": " + entries, 0, entries.size());
}
Also used : Entry(org.apache.directory.api.ldap.model.entry.Entry) SearchResultEntry(org.apache.directory.api.ldap.model.message.SearchResultEntry) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) LdapNetworkConnection(org.apache.directory.ldap.client.api.LdapNetworkConnection)

Aggregations

LdapNetworkConnection (org.apache.directory.ldap.client.api.LdapNetworkConnection)24 Entry (org.apache.directory.api.ldap.model.entry.Entry)11 DefaultEntry (org.apache.directory.api.ldap.model.entry.DefaultEntry)10 SearchResultEntry (org.apache.directory.api.ldap.model.message.SearchResultEntry)8 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)5 Test (org.testng.annotations.Test)5 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 Task (com.evolveum.midpoint.task.api.Task)4 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)4 IOException (java.io.IOException)4 CursorException (org.apache.directory.api.ldap.model.cursor.CursorException)4 Dn (org.apache.directory.api.ldap.model.name.Dn)3 LdapConnectionConfig (org.apache.directory.ldap.client.api.LdapConnectionConfig)3 ApiOperation (io.swagger.annotations.ApiOperation)2 URI (java.net.URI)2 BadRequestException (javax.ws.rs.BadRequestException)2 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2