def simple_bind_s(self, dn, password): """This method is ignored, but provided for compatibility.""" if server_fail: raise ldap.SERVER_DOWN LOG.debug(_('FakeLdap bind dn=%s'), dn) if dn == 'cn=Admin' and password == 'password': return try: attrs = self.db['%s%s' % (self.__prefix, dn)] except KeyError: LOG.debug(_('FakeLdap bind fail: dn=%s not found'), dn) raise ldap.NO_SUCH_OBJECT db_password = None try: db_password = attrs['userPassword'][0] except (KeyError, IndexError): LOG.debug(_('FakeLdap bind fail: password for dn=%s not found'), dn) raise ldap.INAPPROPRIATE_AUTH if not utils.ldap_check_password(password, db_password): LOG.debug( _('FakeLdap bind fail: password for dn=%s does' ' not match'), dn) raise ldap.INVALID_CREDENTIALS
def simple_bind_s(self, dn, password): """This method is ignored, but provided for compatibility.""" if server_fail: raise ldap.SERVER_DOWN LOG.debug(_('FakeLdap bind dn=%s'), dn) if dn == 'cn=Admin' and password == 'password': return try: attrs = self.db['%s%s' % (self.__prefix, dn)] except KeyError: LOG.debug(_('FakeLdap bind fail: dn=%s not found'), dn) raise ldap.NO_SUCH_OBJECT db_password = None try: db_password = attrs['userPassword'][0] except (KeyError, IndexError): LOG.debug(_('FakeLdap bind fail: password for dn=%s not found'), dn) raise ldap.INAPPROPRIATE_AUTH if not utils.ldap_check_password(password, db_password): LOG.debug(_('FakeLdap bind fail: password for dn=%s does' ' not match') % dn) raise ldap.INVALID_CREDENTIALS
def simple_bind_s(self, who='', cred='', serverctrls=None, clientctrls=None): """This method is ignored, but provided for compatibility.""" if server_fail: raise ldap.SERVER_DOWN if who == 'cn=Admin' and cred == 'password': return try: attrs = self.db[self.key(who)] except KeyError: LOG.debug('bind fail: who=%s not found', core.utf8_decode(who)) raise ldap.NO_SUCH_OBJECT db_password = None try: db_password = attrs['userPassword'][0] except (KeyError, IndexError): LOG.debug('bind fail: password for who=%s not found', core.utf8_decode(who)) raise ldap.INAPPROPRIATE_AUTH if not utils.ldap_check_password(cred, db_password): LOG.debug('bind fail: password for who=%s does not match', core.utf8_decode(who)) raise ldap.INVALID_CREDENTIALS
def test_hash_ldap_user_password_with_empty_password(self): password = '' user = self._create_test_user(password=password) user_hashed = utils.hash_ldap_user_password(user) password_hashed = user_hashed['password'] self.assertTrue(utils.ldap_check_password(password, password_hashed))