public function checkLdapErrorCode(UserInterface $user, $code, $ldapType)
    {
        if ($ldapType == LdapConnection::TYPE_AD && $code == ResponseCode::AccountLocked) {
            $ex = new LockedException('User account is locked.');
            $ex->setUser($user);
            throw $ex;
        }

        if ($ldapType == LdapConnection::TYPE_AD && $code == ResponseCode::AccountPasswordMustChange) {
            $ex = new CredentialsExpiredException('User credentials have expired.');
            $ex->setUser($user);
            throw $ex;
        }

        if ($ldapType == LdapConnection::TYPE_AD && $code == ResponseCode::AccountDisabled) {
            $ex = new DisabledException('User account is disabled.');
            $ex->setUser($user);
            throw $ex;
        }
    }