class AcmUserContextMapper implements ContextMapper {

    protected LdapUser mapToLdapUser(DirContextAdapter adapter)
    {
        LdapUser user = new LdapUser();
        user.setDirectoryName(acmLdapSyncConfig.getDirectoryName());
        user.setLastName(MapperUtils.getAttribute(adapter, "sn"));
        user.setFirstName(MapperUtils.getAttribute(adapter, "givenName"));

        String fullName = String.format("%s %s", user.getFirstName(), user.getLastName());
        user.setFullName(fullName);

        // because of how the LDAP query paging works, we can no longer return null for the disabled accounts.
        // so we return them, but mark them DISABLED. The DAO will filter them.
        String uac = MapperUtils.getAttribute(adapter, "userAccountControl");
        if (isUserDisabled(uac))
        {
            log.debug("User [{}] is disabled and won't be synced", fullName);
            user.setState(AcmUserState.DISABLED.name());
        }
        else
        {
            user.setState(AcmUserState.VALID.name());
        }

        user.setDistinguishedName(MapperUtils.appendToDn(adapter.getDn().toString(), acmLdapSyncConfig.getBaseDC()));
        String userId = MapperUtils.getAttribute(adapter, acmLdapSyncConfig.getUserIdAttributeName());
        user.setUserId(MapperUtils.buildUserId(userId, acmLdapSyncConfig.getUserDomain()));
        user.setMail(MapperUtils.getAttribute(adapter, acmLdapSyncConfig.getMailAttributeName()));
        user.setCountry(MapperUtils.getAttribute(adapter, "co"));
        user.setCountryAbbreviation(MapperUtils.getAttribute(adapter, "c"));
        user.setCompany(MapperUtils.getAttribute(adapter, "company"));
        user.setDepartment(MapperUtils.getAttribute(adapter, "department"));
        user.setTitle(MapperUtils.getAttribute(adapter, "title"));
        user.setsAMAccountName(MapperUtils.getAttribute(adapter, "samAccountName"));
        user.setUserPrincipalName(MapperUtils.getAttribute(adapter, "userPrincipalName"));
        user.setUid(MapperUtils.getAttribute(adapter, "uid"));
        user.setSortableValue(MapperUtils.getAttribute(adapter, acmLdapSyncConfig.getAllUsersSortingAttribute()));
        user.setPasswordExpirationDate(Directory.valueOf(acmLdapSyncConfig.getDirectoryType()).getPasswordExpirationDate(adapter));
        return user;
    }

    public  AcmUserContextMapper(AcmLdapSyncConfig acmLdapSyncConfig);

}