def unbind_s(self):
     """
     In addition to unbinding from LDAP, we need to close the shelf.
     """
     if self.using_shelve is True:
         self.data.close()
         self.uuid_dn.close()
         self.dn_attrs.close()
     SimpleLDAPObject.unbind_s(self)
Example #2
0
print "add", acctdn, "to acctPolicySubentry in", userdn2
mod = [(ldap.MOD_REPLACE, 'acctPolicySubentry', acctdn)]
srv.modify_s(userdn2, mod)

print "bind as", userdn2
conn = SimpleLDAPObject('ldap://%s:%d' % (host1, port1))
try:
    conn.simple_bind_s(userdn2, 'normal')
except ldap.CONSTRAINT_VIOLATION:
    print "user is prevented from logging in after", inactivetime2, "seconds of inactivity"
    ents = srv.search_s(basedn, ldap.SCOPE_SUBTREE, 'uid=mward', ['lastLoginTime', 'createTimestamp'])
    print "lastLoginTime:", ents[0].lastLoginTime
time.sleep(1)

print "the entry with lastLoginTime"
ents = srv.search_s(basedn, ldap.SCOPE_SUBTREE, 'uid=mward', ['lastLoginTime', 'createTimestamp'])
pprint.pprint(ents)

print "sleep", inactivetime2
time.sleep(inactivetime2)

print "bind as", userdn2
try:
    conn.simple_bind_s(userdn2, 'normal')
except ldap.CONSTRAINT_VIOLATION:
    print "user is prevented from logging in after", inactivetime2, "seconds of inactivity"
    ents = srv.search_s(basedn, ldap.SCOPE_SUBTREE, 'uid=mward', ['*', 'lastLoginTime', 'createTimestamp'])
    print "lastLoginTime:", ents[0].lastLoginTime
conn.unbind_s()