本文整理匯總了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
示例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