當前位置: 首頁>>代碼示例>>Python>>正文


Python LDAPClient.add_user方法代碼示例

本文整理匯總了Python中placard.client.LDAPClient.add_user方法的典型用法代碼示例。如果您正苦於以下問題:Python LDAPClient.add_user方法的具體用法?Python LDAPClient.add_user怎麽用?Python LDAPClient.add_user使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在placard.client.LDAPClient的用法示例。


在下文中一共展示了LDAPClient.add_user方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: activate_user

# 需要導入模塊: from placard.client import LDAPClient [as 別名]
# 或者: from placard.client.LDAPClient import add_user [as 別名]
    def activate_user(self, person):
        person = super(PersonalDataStore, self).activate_user(person)

        attrs = {}
        attrs['uid'] = str(person.username)
        attrs['givenName'] = str(person.first_name)
        attrs['sn'] = str(person.last_name)
        attrs['telephoneNumber'] = str(person.telephone)
        attrs['mail'] = str(person.email)
        attrs['o'] = str(person.institute.name)
        attrs['title'] = str(person.title)
        attrs['userPassword'] = str(person.user.password)
        
        conn = LDAPClient()
        conn.add_user(**attrs)
        person.user.set_unusable_password()
        person.user.save()
        person.save(update_datastore=False)
        del(conn)
        return person
開發者ID:levlafayette,項目名稱:karaage,代碼行數:22,代碼來源:ldap_datastore.py

示例2: activate_user

# 需要導入模塊: from placard.client import LDAPClient [as 別名]
# 或者: from placard.client.LDAPClient import add_user [as 別名]
 def activate_user(self, person):
     person = super(PersonalDataStore, self).activate_user(person)
     attrs = {}
     attrs['sAMAccountName'] = str(person.username)
     attrs['givenName'] = str(person.first_name)
     attrs['sn'] = str(person.last_name)
     attrs['telephoneNumber'] = str(person.telephone)
     attrs['mail'] = str(person.email)
     attrs['o'] = str(person.institute.name)
     conn = LDAPClient()
     dn = conn.add_user(**attrs)
     person.save(update_datastore=False)
     
     # Set password then unlock account
     if person.user.password != '!':
         import ldap
         mod_attrs = [(ldap.MOD_REPLACE, 'unicodePwd', str(person.user.password)), (ldap.MOD_REPLACE, 'unicodePwd', str(person.user.password))]
         conn.conn.modify_s(dn, mod_attrs)
         conn.update_user('sAMAccountName=%s' % str(person.username), userAccountControl=512)
         
     person.user.set_unusable_password()
     person.user.save()
     del(conn)
     return person
開發者ID:levlafayette,項目名稱:karaage,代碼行數:26,代碼來源:ad_datastore.py


注:本文中的placard.client.LDAPClient.add_user方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。