public static void modifyLdapEntry(final LDAPConnection serverCon, final String dn,
                                       final LdapAttribute attr,
                                       final AttributeModification.Type add,
                                       final BindConnectionInitializer connInit) {

        val address = "ldap://" + serverCon.getConnectedAddress() + ':' + serverCon.getConnectedPort();
        val config = new ConnectionConfig(address);
        if (connInit != null) {
            config.setConnectionInitializers(connInit);
        }
        LOGGER.debug("Created modification request connection configuration [{}] for [{}]", config, address);
        val connectionFactory = new DefaultConnectionFactory(config);
        try {
            val modify = new ModifyOperation(connectionFactory);
            val request = new ModifyRequest(dn, new AttributeModification(add, attr));
            LOGGER.debug("Executing modification request [{}] with type [{}] for [{}]", request, add, dn);
            val result = modify.execute(request);
            if (!result.isSuccess()) {
                LOGGER.warn("Result [{}]:[{}]", result.getResultCode(), result.getDiagnosticMessage());
            }
        } catch (final Exception e) {
            LOGGER.info(e.getMessage(), e);
        } finally {
            connectionFactory.close();
        }
    }
Modify ldap entry.

@param serverCon the server con
@param dn        the dn
@param attr      the attr
@param add       the add
@param connInit  the connection initializer
support/cas-server-support-ldap-core/src/test/java/org/apereo/cas/util/LdapTestUtils.java