@Override
    public LdapEntry mapFromRegisteredService(final String dn, final RegisteredService svc) {
        if (svc.getId() == RegisteredServiceDefinition.INITIAL_IDENTIFIER_VALUE) {
            val id = System.currentTimeMillis();
            svc.setId(id);
        }
        val newDn = getDnForRegisteredService(dn, svc);
        LOGGER.debug("Creating entry DN [{}]", newDn);

        val attrs = new ArrayList<LdapAttribute>(3);
        attrs.add(new LdapAttribute(ldap.getIdAttribute(), String.valueOf(svc.getId())));

        return FunctionUtils.doUnchecked(() -> {
            try (val writer = new StringWriter()) {
                this.jsonSerializer.to(writer, svc);
                val defn = writer.toString();
                attrs.add(new LdapAttribute(ldap.getServiceDefinitionAttribute(), defn));
                attrs.add(new LdapAttribute(LdapUtils.OBJECT_CLASS_ATTRIBUTE, "top", ldap.getObjectClass()));
            }
            LOGGER.debug("LDAP attributes assigned to the DN [{}] are [{}]", newDn, attrs);
            val entry = LdapEntry.builder().dn(newDn).attributes(attrs).build();
            LOGGER.debug("Constructed LDAP entry [{}]", entry);
            return entry;
        });

    }
Default implementation of {@link LdapRegisteredServiceMapper} that is able
to map ldap entries to {@link RegisteredService} instances based on
certain attributes names. This implementation also respects the object class
attribute of LDAP entries via {@link LdapUtils#OBJECT_CLASS_ATTRIBUTE}.

@author Misagh Moayyed
@since 4.1.0
support/cas-server-support-ldap-service-registry/src/main/java/org/apereo/cas/adaptors/ldap/services/DefaultLdapRegisteredServiceMapper.java