Пример #1
0
for ii in myiter:
    dn = "cn=%d, %s" % (ii, basedn)
    svr = (m1,m2)[ii % 2]
    ent = Entry(dn)
    ent.setValues('objectclass', 'person')
    ent.setValues('sn', 'testuser')
    ent.setValues('description', 'added description')
    svr.add_s(ent)
    print "Added", dn

print "Sleep for 20 seconds to let changes propagate . . ."
time.sleep(20)
print "Verify all entries are present in both servers . . ."
for ii in myiter:
    dn = "cn=%d, %s" % (ii, basedn)
    ent = m1.getEntry(dn, ldap.SCOPE_BASE)
    if not ent: raise "Entry %s not found in %s" % (dn, m1)
    ent = m2.getEntry(dn, ldap.SCOPE_BASE)
    if not ent: raise "Entry %s not found in %s" % (dn, m2)

print "Delete description attr in all entries . . ."
for ii in myiter:
    dn = "cn=%d, %s" % (ii, basedn)
    jj = ii + 1
    svr = (m1,m2)[jj % 2]
    delit = [(ldap.MOD_DELETE, 'description', None)]
    svr.modify_s(dn, delit)
    print "Modified", dn

print "Sleep for 20 seconds to let changes propagate . . ."
time.sleep(20)