本文整理汇总了Python中ldapcherry.backend.backendLdap.Backend.add_user方法的典型用法代码示例。如果您正苦于以下问题:Python Backend.add_user方法的具体用法?Python Backend.add_user怎么用?Python Backend.add_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ldapcherry.backend.backendLdap.Backend
的用法示例。
在下文中一共展示了Backend.add_user方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testModifyUser
# 需要导入模块: from ldapcherry.backend.backendLdap import Backend [as 别名]
# 或者: from ldapcherry.backend.backendLdap.Backend import add_user [as 别名]
def testModifyUser(self):
inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
user = {
'uid': u'test☭',
'sn': u'test☭',
'cn': u'test☭',
'userPassword': u'test☭',
'uidNumber': '42',
'gidNumber': '42',
'homeDirectory': '/home/test/'
}
inv.add_user(user)
inv.set_attrs(u'test☭', {'gecos': 'test2', 'homeDirectory': '/home/test/'})
inv.del_user(u'test☭')
示例2: testAddUserMissingMustattribute
# 需要导入模块: from ldapcherry.backend.backendLdap import Backend [as 别名]
# 或者: from ldapcherry.backend.backendLdap.Backend import add_user [as 别名]
def testAddUserMissingMustattribute(self):
inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
user = {
'uid': u'test☭',
'sn': u'test☭',
'cn': u'test☭',
'userPassword': u'test☭',
'gidNumber': '42',
'homeDirectory': '/home/test/'
}
try:
inv.add_user(user)
except ldap.OBJECT_CLASS_VIOLATION:
return
else:
inv.del_user(u'test☭')
raise AssertionError("expected an exception")
示例3: testAddUser
# 需要导入模块: from ldapcherry.backend.backendLdap import Backend [as 别名]
# 或者: from ldapcherry.backend.backendLdap.Backend import add_user [as 别名]
def testAddUser(self):
try:
inv.del_user(u'test☭,cn=')
except:
pass
inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
user = {
'uid': u'test☭,cn=',
'sn': u'test☭',
'cn': u'test☭',
'userPassword': u'test☭',
'uidNumber': '42',
'gidNumber': '42',
'homeDirectory': '/home/test/'
}
inv.add_user(user)
inv.del_user(u'test☭,cn=')
示例4: testAddUserDuplicate
# 需要导入模块: from ldapcherry.backend.backendLdap import Backend [as 别名]
# 或者: from ldapcherry.backend.backendLdap.Backend import add_user [as 别名]
def testAddUserDuplicate(self):
inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
user = {
'uid': u'test☭',
'sn': u'test☭',
'cn': u'test☭',
'uidNumber': '42',
'userPassword': u'test☭',
'gidNumber': '42',
'homeDirectory': '/home/test/'
}
try:
inv.add_user(user)
inv.add_user(user)
except UserAlreadyExists:
inv.del_user(u'test☭')
return
else:
inv.del_user(u'test☭')
raise AssertionError("expected an exception")
示例5: Backend
# 需要导入模块: from ldapcherry.backend.backendLdap import Backend [as 别名]
# 或者: from ldapcherry.backend.backendLdap.Backend import add_user [as 别名]
cherrypy.log.error = syslog_error
inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
print inv.get_user('jwatson')
print inv.get_groups('jwatson')
print inv.search('smit')
user = {
'uid': 'test',
'sn': 'test',
'cn': 'test',
'userPassword': 'test',
'uidNumber': '42',
'gidNumber': '42',
'homeDirectory': '/home/test/'
}
inv.add_user(user)
print inv.get_user('test')
print inv.get_groups('test')
inv.del_user('test')
groups = [
'cn=hrpeople,ou=Groups,dc=example,dc=org',
'cn=itpeople,ou=Groups,dc=example,dc=org',
]
inv.add_to_groups('jwatson', groups)
ret = inv.get_groups('jwatson')
print ret
inv.del_from_groups('jwatson', ['cn=hrpeople,ou=Groups,dc=example,dc=org'])
inv.del_from_groups('jwatson', ['cn=hrpeople,ou=Groups,dc=example,dc=org'])