public void updateUsersAttributeInLDAP(String userId, String ldapAttrName, String[] records) { DirContextOperations context = ldapTemplate.lookupContext(getUserDN(userId)); context.setAttributeValues(ldapAttrName, records); ldapTemplate.modifyAttributes(context); log.debug("Entry modified in LDAP: UserId {}.", userId); }
public void supprimerMembreViaMajMembre(String dnProfil, String dnMembre) throws ToutaticeAnnuaireException, javax.naming.NamingException { Profil profilMaj = this.findByDn(dnProfil); profilMaj.removeMember(dnMembre); //si le membre était un membre explicite on le retire aussi de cette liste profilMaj.removeExplicitMember(dnMembre); //elimination des doublons profilMaj.setListeExplicitMembers(new ArrayList(new HashSet(profilMaj.getListeExplicitMembers()))); Name dn = this.buildDn(profilMaj); DirContextOperations context = ldapTemplateEcriture.lookupContext(dn); Object[] explicitMembers = new Object[profilMaj.getListeExplicitMembers().size()]; int i = 0; for (Object o : profilMaj.getListeExplicitMembers()) { explicitMembers[i] = o; i++; } context.setAttributeValues(explicitMember, explicitMembers); Object[] members = new Object[profilMaj.getListeMembers().size()]; i = 0; for (Object o : profilMaj.getListeMembers()) { members[i] = o; i++; } context.setAttributeValues(member, members); ldapTemplateEcriture.modifyAttributes(context); }
protected void mapToContext(final UserOrg entry, final DirContextOperations context) { context.setAttributeValue("cn", entry.getFirstName() + " " + entry.getLastName()); context.setAttributeValue(SN_ATTRIBUTE, entry.getLastName()); context.setAttributeValue(GIVEN_NAME_ATTRIBUTE, entry.getFirstName()); context.setAttributeValue(uidAttribute, Normalizer.normalize(entry.getId())); context.setAttributeValues(MAIL_ATTRIBUTE, entry.getMails().toArray(), true); // Special and also optional attributes Optional.ofNullable(departmentAttribute).ifPresent(a -> context.setAttributeValue(a, entry.getDepartment())); Optional.ofNullable(localIdAttribute).ifPresent(a -> context.setAttributeValue(a, entry.getLocalId())); }
public void updateMembers(RoleApplicatif role) throws ToutaticeAnnuaireException { logger.debug("entree dans la methode roleApplicatifDAO.updateMembers"); Name dn = buildDn(role); Object[] members = new Object[role.getListeMembers().size()]; int i = 0; for (Object o : role.getListeMembers()) { members[i] = o; i++; } try { DirContextOperations context = ldapTemplateEcriture.lookupContext(dn); context.setAttributeValues(RoleApplicatifDaoImpl.membres, members); ldapTemplateEcriture.modifyAttributes(context); } catch (NamingException e) { logger.error("Les membres du role " + role.getCn() + "n'ont pas pu être mis à jour" ); throw new ToutaticeAnnuaireException("Erreur de mise à jour des membres du role applicatif "+role.getCn()); } }
context.setAttributeValues(password, pwd); ldapTemplateEcriture.modifyAttributes(context); loggerModif.info("La personne "+p.getUid()+" a été modifiée");
public void updateRne(Person p) throws ToutaticeAnnuaireException { //elimination des doublons p.setListeRnes(Helper.supprimerDoublonsCaseNonSensitive(p.getListeRnes())); Name dn = buildDn(p); Object[] listeRne = new Object[p.getListeRnes().size()]; int i = 0; for (Object o : p.getListeRnes()) { listeRne[i] = o; i++; } try { DirContextOperations context = ldapTemplateEcriture.lookupContext(dn); context.setAttributeValues(PersonDaoImpl.rne, listeRne); ldapTemplateEcriture.modifyAttributes(context); loggerModif.info("La personne "+p.getUid()+" a été modifiée"); } catch (NamingException e) { logger.error("Impossible de mettre à jour les rne de la personne "+p.getUid()); logger.error(e.toString()); throw new ToutaticeAnnuaireException("Erreur lors de la mise à jour des rne de la personne "+p.getUid()+" dans l'annuaire"); } }
public void ajoutMembreViaMajMembre(String dnProfil, String dnMembre) throws ToutaticeAnnuaireException, javax.naming.NamingException { Profil profilMaj = this.findByDn(dnProfil); profilMaj.addMember(dnMembre); //elimination des doublons profilMaj.setListeExplicitMembers(new ArrayList(new HashSet(profilMaj.getListeExplicitMembers()))); Name dn = this.buildDn(profilMaj); if (profilMaj.getListeMembers().size() > 0) { Object[] members = new Object[profilMaj.getListeMembers().size()]; int i = 0; for (Object o : profilMaj.getListeMembers()) { members[i] = o; i++; } DirContextOperations context = ldapTemplateEcriture.lookupContext(dn); context.setAttributeValues(member, members); ldapTemplateEcriture.modifyAttributes(context); } else // Si il n'y a aucun membre on supprime l'attribut { if(profilMaj.getListeMembers().size() > 0) { BasicAttribute attrMembers = new BasicAttribute(member, false); attrMembers.add(null); ModificationItem item = new ModificationItem( DirContext.REMOVE_ATTRIBUTE, attrMembers); ldapTemplateEcriture.modifyAttributes(dn, new ModificationItem[] { item }); } } }
context.setAttributeValues(PersonDaoImpl.profils, listeProfils); ldapTemplateEcriture.modifyAttributes(context); } catch (NamingException e) {
context.setAttributeValues(manager, managers); ldapTemplateEcriture.modifyAttributes(context); loggerModif.info("La personne "+personMaj.getUid()+" a été modifiée");
context.setAttributeValues(explicitManager, explicitManagers); ldapTemplateEcriture.modifyAttributes(context); loggerModif.info("La personne "+personMaj.getUid()+" a été modifiée");
@Test public void verifyCompleteReplacementOfUniqueMemberAttribute_Ldap119Workaround() { DirContextOperations ctx = tested.lookupContext("cn=ROLE_USER,ou=groups"); ctx.setAttributeValues("uniqueMember", new String[]{"cn=Some Person,ou=company1,ou=Norway," + base}, true); ctx.getModificationItems(); tested.modifyAttributes(ctx); }
context.setAttributeValues(ApplicationDaoImpl.manager, managers); ldapTemplateEcriture.modifyAttributes(context); } catch (NamingException e) {
/** * This test originally failed on ApacheDS complaining that the uniqueMember attribute * was emptied. */ @Test public void verifyCompleteReplacementOfUniqueMemberAttribute_Ldap119() { DirContextOperations ctx = tested.lookupContext("cn=ROLE_USER,ou=groups"); ctx.setAttributeValues("uniqueMember", new String[]{"cn=Some Person,ou=company1,ou=Norway," + base}); ctx.getModificationItems(); tested.modifyAttributes(ctx); } private Attributes setupAttributes() {
context.setAttributeValues(ApplicationDaoImpl.profils, profils); ldapTemplateEcriture.modifyAttributes(context); } catch (NamingException e) {
context.setAttributeValues(ApplicationDaoImpl.explicitManager, explicitManagers); ldapTemplateEcriture.modifyAttributes(context); } catch (NamingException e) {
context.setAttributeValues(RoleApplicatifDaoImpl.explicitManager, explicitManagers); ldapTemplateEcriture.modifyAttributes(context); } catch (NamingException e) {
context.setAttributeValues(RoleApplicatifDaoImpl.memberURL, memberURLTab); ldapTemplateEcriture.modifyAttributes(context); } catch (NamingException e) {
context.setAttributeValues(RoleApplicatifDaoImpl.owner, owner); ldapTemplateEcriture.modifyAttributes(context); } catch (NamingException e) {
context.setAttributeValues(RoleApplicatifDaoImpl.profilsApplicatifs, profil); ldapTemplateEcriture.modifyAttributes(context); } catch (NamingException e) {
context.setAttributeValues(RoleApplicatifDaoImpl.manager, managers); ldapTemplateEcriture.modifyAttributes(context); } catch (NamingException e) {