本文整理汇总了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