@Override
    public boolean submit(final RequestContext requestContext) {
        val principal = WebUtils.getAuthentication(requestContext).getPrincipal();
        val response = aupProperties.getLdap()
            .stream()
            .sorted(Comparator.comparing(LdapAcceptableUsagePolicyProperties::getName))
            .map(Unchecked.function(ldap -> searchLdapForId(ldap, principal.getId())))
            .filter(Optional::isPresent)
            .findFirst();

        if (response.isPresent()) {
            val result = response.get().orElseThrow();
            val currentDn = result.getMiddle().getEntry().getDn();
            LOGGER.debug("Updating [{}]", currentDn);
            val attributes = CollectionUtils.<String, Set<String>>wrap(aupProperties.getCore().getAupAttributeName(),
                CollectionUtils.wrapSet(result.getRight().getAupAcceptedAttributeValue()));
            val factory = new LdapConnectionFactory(result.getLeft());
            return factory.executeModifyOperation(currentDn, attributes);
        }
        return false;
    }
Search ldap for id and return optional.

@param ldap the ldap
@param id   the id
@return the optional
@throws Exception the exception
support/cas-server-support-aup-ldap/src/main/java/org/apereo/cas/aup/LdapAcceptableUsagePolicyRepository.java