Search in sources :

Example 1 with DefaultModification

use of org.apache.directory.api.ldap.model.entry.DefaultModification in project midpoint by Evolveum.

the class AbstractAdLdapTest method doAdditionalRenameModifications.

@Override
protected void doAdditionalRenameModifications(LdapNetworkConnection connection) throws LdapException {
    Modification mod = new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, ATTRIBUTE_SAM_ACCOUNT_NAME_NAME, ACCOUNT_HTM_UID);
    connection.modify(toAccountDn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN), mod);
    display("Modified " + toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN) + " " + ATTRIBUTE_SAM_ACCOUNT_NAME_NAME + " -> " + ACCOUNT_HTM_UID + ": " + mod);
}
Also used : DefaultModification(org.apache.directory.api.ldap.model.entry.DefaultModification) Modification(org.apache.directory.api.ldap.model.entry.Modification) DefaultModification(org.apache.directory.api.ldap.model.entry.DefaultModification)

Example 2 with DefaultModification

use of org.apache.directory.api.ldap.model.entry.DefaultModification in project midpoint by Evolveum.

the class AbstractLdapSynchronizationTest method test822ModifyAccountHt.

@Test
public void test822ModifyAccountHt() throws Exception {
    final String TEST_NAME = "test822ModifyAccountHt";
    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(), 7, 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 3 with DefaultModification

use of org.apache.directory.api.ldap.model.entry.DefaultModification 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)

Aggregations

DefaultModification (org.apache.directory.api.ldap.model.entry.DefaultModification)3 Modification (org.apache.directory.api.ldap.model.entry.Modification)3 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 Task (com.evolveum.midpoint.task.api.Task)2 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)2 LdapNetworkConnection (org.apache.directory.ldap.client.api.LdapNetworkConnection)2 Test (org.testng.annotations.Test)2