本文整理汇总了Python中dsadmin.DSAdmin.delete_s方法的典型用法代码示例。如果您正苦于以下问题:Python DSAdmin.delete_s方法的具体用法?Python DSAdmin.delete_s怎么用?Python DSAdmin.delete_s使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dsadmin.DSAdmin
的用法示例。
在下文中一共展示了DSAdmin.delete_s方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: genpwd
# 需要导入模块: from dsadmin import DSAdmin [as 别名]
# 或者: from dsadmin.DSAdmin import delete_s [as 别名]
srv.add_s(ent)
except ldap.ALREADY_EXISTS:
pass
def genpwd(pwd, salt):
sha = hashlib.sha1(pwd)
sha.update(salt)
return "{SSHA}" + base64.b64encode(sha.digest() + salt)
pwd = "averylongpassword"
for ii in xrange(0, 100):
dn = "cn=user%d,ou=people,%s" % (ii, basedn)
try:
srv.delete_s(dn)
except ldap.NO_SUCH_OBJECT:
pass
ent = Entry(dn)
ent.setValues("objectclass", "person")
ent.setValues("sn", "User" + str(ii))
if ii > 0:
salt = "a" * ii
pwdstr = genpwd(pwd, salt)
else:
pwdstr = pwd
ent.setValues("userPassword", pwdstr)
srv.add_s(ent)
for ii in xrange(0, 100):
dn = "cn=user%d,ou=people,%s" % (ii, basedn)
示例2: xrange
# 需要导入模块: from dsadmin import DSAdmin [as 别名]
# 或者: from dsadmin.DSAdmin import delete_s [as 别名]
time.sleep(20)
print "check entries in DS - see if they have title and enabled state correct"
for ii in xrange(1,11):
filt = "(uid=testuser%d)" % ii
ents = ds.search_s(usersubtree + "," + suffix, ldap.SCOPE_SUBTREE, filt, dsattrs)
if not ents or len(ents) == 0 or not ents[0]:
raise Exception("error: " + filt + " not found in DS")
dsent = ents[0]
adent = adents[ii-1]
if not entriesAreEqual(dsent, adent):
print "entries are not equal", dsent.dn, adent.dn
print "delete all entries in AD - at the same time, modify an entry in DS . . ."
for ent in adents:
ad.delete_s(ent.dn)
ad.delete_s(adusersubtree + "," + suffix)
time.sleep(1)
mod = [(ldap.MOD_REPLACE, 'userPassword', 'Ornette1')]
ds.modify_s(dsents[0].dn, mod)
print "delete all entries in DS"
for ent in dsents:
try: ds.delete_s(ent.dn)
except ldap.NO_SUCH_OBJECT: print ent.dn, "already deleted"
print "add back the deleted container"
ent = Entry(windows_subtree)
rdn = ldap.explode_dn(windows_subtree)[0].split('=')
ent.setValues('objectclass', ['top', 'container'])
ent.setValues(rdn[0], rdn[1])