public void updateAndRename(String dn, String newDn, String updatedDescription) { DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn); ctx.setAttributeValue("description", updatedDescription); ldapTemplate.modifyAttributes(ctx); ldapTemplate.rename(dn, newDn); }
public void updateAndRename(String dn, String newDn, String description) { DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn); ctx.setAttributeValue("description", description); ldapTemplate.modifyAttributes(ctx); ldapTemplate.rename(dn, newDn); }
public void updateAndRename(String dn, String newDn, String description) { DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn); ctx.setAttributeValue("description", description); ldapTemplate.modifyAttributes(ctx); ldapTemplate.rename(dn, newDn); }
@Test public void testRename_NamingException() throws Exception { expectGetReadWriteContext(); javax.naming.NamingException ne = new javax.naming.NamingException(); doThrow(ne).when(dirContextMock).rename(oldNameMock, newNameMock); try { tested.rename(oldNameMock, newNameMock); fail("UncategorizedLdapException expected"); } catch (UncategorizedLdapException expected) { assertThat(true).isTrue(); } verify(dirContextMock).close(); }
@Test public void testRename() throws Exception { expectGetReadWriteContext(); tested.rename(oldNameMock, newNameMock); verify(dirContextMock).rename(oldNameMock, newNameMock); verify(dirContextMock).close(); }
@Test public void testRename_String() throws Exception { expectGetReadWriteContext(); tested.rename("o=example.com", "o=somethingelse.com"); verify(dirContextMock).rename("o=example.com", "o=somethingelse.com"); verify(dirContextMock).close(); } }
@Test public void testRename_NameAlreadyBoundException() throws Exception { expectGetReadWriteContext(); javax.naming.NameAlreadyBoundException ne = new javax.naming.NameAlreadyBoundException(); doThrow(ne).when(dirContextMock).rename(oldNameMock, newNameMock); try { tested.rename(oldNameMock, newNameMock); fail("NameAlreadyBoundException expected"); } catch (NameAlreadyBoundException expected) { assertThat(true).isTrue(); } verify(dirContextMock).close(); }
@Test public void testRename() { tested.rename(DN, NEWDN); verifyDeleted(LdapUtils.newLdapName(DN)); verifyBoundCorrectData(); }
@Override public void move(final UserOrg user, final CompanyOrg company) { final LdapName newDn = org.springframework.ldap.support.LdapUtils .newLdapName(buildDn(user.getId(), company.getDn())); final LdapName oldDn = org.springframework.ldap.support.LdapUtils.newLdapName(user.getDn()); template.rename(oldDn, newDn); user.setDn(newDn.toString()); user.setCompany(company.getId()); cacheRepository.update(user); // Also, update the groups of this user user.getGroups().forEach(g -> groupLdapRepository.updateMemberDn(g, oldDn.toString(), newDn.toString())); }
@Test public void testRename_LdapName() throws Exception { Name oldDn = LdapUtils.newLdapName(DN); Name newDn = LdapUtils.newLdapName(NEWDN); tested.rename(oldDn, newDn); verifyDeleted(oldDn); verifyBoundCorrectData(); }