示例#1
0
 def changePassword(self, password, confirm):
     if password != confirm:
         return "Waaaaa!"
     encrypted_pw = '{SSHA}' + SSHA.encrypt(password).strip()
     dbc = self._get_ldap_connection()
     dbc.modify(
         "%s=%s,%s" % (
             IUser['__name__'].ldap_name,
             self.__name__,
             self.ldap_user_search_base,
         ), {'userPassword': [encrypted_pw]})
示例#2
0
文件: user.py 项目: bcgsc/gum
 def changePassword(self, password, confirm):
     if password != confirm:
         return "Waaaaa!"
     encrypted_pw = '{SSHA}' + SSHA.encrypt(password).strip()
     dbc = self._get_ldap_connection()
     dbc.modify(
         "%s=%s,%s" % (
             IUser['__name__'].ldap_name,
             self.__name__,
             self.ldap_user_search_base,
         ),
         {'userPassword':[encrypted_pw]}
     )
示例#3
0
def _createLDAPPassword(password, encoding='SHA'):
    """ Create a password string suitable for userPassword """
    if encoding == 'SSHA':
        pwd_str = '{SSHA}' + SSHA.encrypt(password)
    elif encoding == 'crypt':
        saltseeds = list('%s%s' % ( string.lowercase[:26]
                                  , string.uppercase[:26]
                                  ) )
        salt = ''
        for n in range(2):
            salt += random.choice(saltseeds)
        pwd_str = '{crypt}%s' % crypt.crypt(password, salt)
    elif encoding == 'md5':
        m = md5.new(password)
        pwd_str = '{md5}' + base64.encodestring(m.digest())
    elif encoding == 'clear':
        pwd_str = password
    else:
        sha_obj = sha.new(password)
        pwd_str = '{SHA}' + base64.encodestring(sha_obj.digest())

    return pwd_str.strip()
示例#4
0
def _createLDAPPassword(password, encoding='SHA'):
    """ Create a password string suitable for userPassword """
    if encoding == 'SSHA':
        pwd_str = '{SSHA}' + SSHA.encrypt(password)
    elif encoding == 'crypt':
        saltseeds = list('%s%s' % ( string.lowercase[:26]
                                  , string.uppercase[:26]
                                  ) )
        salt = ''
        for n in range(2):
            salt += random.choice(saltseeds)
        pwd_str = '{crypt}%s' % crypt.crypt(password, salt)
    elif encoding == 'md5':
        m = md5.new(password)
        pwd_str = '{md5}' + base64.encodestring(m.digest())
    elif encoding == 'clear':
        pwd_str = password
    else:
        sha_obj = sha.new(password)
        pwd_str = '{SHA}' + base64.encodestring(sha_obj.digest())

    return pwd_str.strip()