class LdapCustomAuthenticationProvider extends LdapAuthenticationProvider {

    protected Principal mergeUsers(LdapUserDetails ldapUser, Principal principalFromDB, String password) {
    	User user;
    	Boolean console = false;
    	
    	if(principalFromDB.getUser() == null){
    		user = new User();
    		console = true;
    	}else {
    		user = principalFromDB.getUser();
    	}
    	
        user.setDn(ldapUser.getDn());
        user.setLdapName(ldapUser.getDn().replace(",dc=autentia,dc=com", ""));
        user.setLdapPassword(password);
        user.setActive(ldapUser.isEnabled());
        user.setPasswordExpired(checkExpiredPassword(ldapUser.getAttributes()));
        user.setResetPassword(checkResetPassword(ldapUser.getAttributes()));
        
        Principal ret;
        if(console){
        	ret = new Principal(999, 999, user.getLdapName(), user.getLdapPassword(),
        			 user.isActive(),user.getName(), 999, principalFromDB.getAuthorities());
        }else{
        	ret = new Principal(user, user.getLdapPassword(), principalFromDB.getAuthorities());
        }
        return ret;
    }

    public  LdapCustomAuthenticationProvider(LdapAuthenticator authenticator,
                                            LdapAuthoritiesPopulator authoritiesPopulator);

}