Пример #1
0
ents = m1.search_s("cn=monitor", ldap.SCOPE_BASE, "(objectclass=*)", ["currentconnections", "connection"])
for ent in ents:
    print ent
print "start search request . . ."
scope = ldap.SCOPE_SUBTREE
filter = "(|(objectclass=*)(objectclass=nsTombstone))"
serverctrls = [TestCtrl()]
ents = m1.search_s(basedn, scope, filter)
print "search returned %d entries" % len(ents)
print "send abandon with controls . . ."
m1.abandon_ext(999, serverctrls)
print "send abandon without controls . . ."
msgid2 = m1.abandon_ext(999)
print "send unbind with controls . . ."
# for some reason, unbind_ext_s is not passing
# controls passed in - so have to set_option
m1.set_option(ldap.OPT_SERVER_CONTROLS, serverctrls)
m1.unbind_ext_s(serverctrls)
print "try a search after the unbind . . ."
try:
    ents = m1.search_s(basedn, scope, filter)
except ldap.LDAPError, e:
    print "caught exception", e

print "open new connection . . ."
m1 = DSAdmin(host1, port1, binddn, bindpw)
print "show active connections . . ."
ents = m1.search_s("cn=monitor", ldap.SCOPE_BASE, "(objectclass=*)", ["currentconnections", "connection"])
for ent in ents:
    print ent
Пример #2
0
    initfile = "%s/share/dirsrv/data/Example.ldif" % os.environ.get(
        'PREFIX', '/usr')

m1.importLDIF(initfile, '', "userRoot", True)

#m1.setLogLevel(65535)
print "Add the filtered group entry with bogus filter"
dn = "cn=TestDynamicGroup,dc=example,dc=com"
ent = Entry(dn)
ent.setValues('description', "Dynamic test group")
ent.setValues('objectclass', 'top', 'groupofuniquenames', 'groupofurls')
ent.setValues(
    'memberurl',
    'ldap:///dc=example,dc=com??sub?(&(objectclass=person)(uid=scart*)')
#ent.cn = 'TestDynamicGroup'
m1.add_s(ent)

print "Add the bogus aci for that group"
addmod = [(
    ldap.MOD_REPLACE, 'aci',
    '(targetattr = "*") (version 3.0;acl "Test Crash ACL";allow (all)(groupdn = "ldap:///cn=TestDynamicGroup,dc=example,dc=com");)'
)]
m1.modify_s("dc=example,dc=com", addmod)
#m1.setLogLevel(0)

print "Do a search binding as a member of the group"
conn = DSAdmin(host1, port1, "uid=scarter,ou=people,dc=example,dc=com",
               "sprain")
entries = conn.search_s("uid=scarter,ou=people,dc=example,dc=com",
                        ldap.SCOPE_BASE, "objectclass=*")
Пример #3
0
print "repl status:", ds.getReplStatus(agmtdn)

idnum = 6
ent = makeDSUserEnt()
uid = ent.uid
print "Now adding", uid, "to DS . . ."
ds.add_s(ent)
time.sleep(1)
ents = ds.search_s(suffix, scope, "(uid=%s)" % uid, attrs)
ent = ents[0]
print "Added entry to DS, adding telephonenumber . . ."
mod = [(ldap.MOD_ADD, 'telephoneNumber', telnum1)]
ds.modify_s(ent.dn, mod)
time.sleep(1)
print "Making entry a sync-able entry . . ."
mod = [(ldap.MOD_DELETE, 'telephoneNumber', telnum1),
       (ldap.MOD_ADD, 'telephoneNumber', telnum2),
       (ldap.MOD_ADD, 'description', 'test bug206966'),
       (ldap.MOD_ADD, 'objectclass', 'ntUser'),
       (ldap.MOD_ADD, 'ntUserDomainId', uid),
       (ldap.MOD_ADD, 'ntUserCreateNewAccount', 'true')
       ]
ds.modify_s(ent.dn, mod)
time.sleep(1)
print "Now compare the entries . . ."
ents = ds.search_s(suffix, scope, "(uid=%s)" % uid)
print "DS Entry: ", str(ents[0])
ents = ad.search_s(suffix, scope, "(samaccountname=%s)" % uid)
print "AD Entry: ", str(ents[0])
Пример #4
0
       (ldap.MOD_ADD, 'ntUserDomainId', uid)]
ds.modify_s(ent.dn, mod)
time.sleep(1)
print "Added ntuser, changing telephonenumber . . ."
mod = [(ldap.MOD_DELETE, 'telephoneNumber', telnum1),
       (ldap.MOD_ADD, 'telephoneNumber', telnum2)]
ds.modify_s(ent.dn, mod)
time.sleep(1)
print "changed telephonenumber, changing description . . ."
mod = [(ldap.MOD_ADD, 'description', 'test bug471068')]
ds.modify_s(ent.dn, mod)
time.sleep(1)

print "Delete description in AD, then in DS . . ."
mod = [(ldap.MOD_DELETE, 'description', None)]
ad.modify_s(adent.dn, mod)
ds.modify_s(ent.dn, mod)

time.sleep(1)
print "Add description in AD, then in DS . . ."
mod = [(ldap.MOD_ADD, 'description', 'test bug471068')]
ad.modify_s(adent.dn, mod)
ds.modify_s(ent.dn, mod)

time.sleep(1)
print "Now compare the entries . . ."
ents = ds.search_s(suffix, scope, "(uid=%s)" % uid)
print "DS Entry: ", str(ents[0])
ents = ad.search_s(suffix, scope, "(samaccountname=%s)" % uid)
print "AD Entry: ", str(ents[0])
Пример #5
0
for ent in ents:
    print ent
print "start search request . . ."
scope = ldap.SCOPE_SUBTREE
filter = '(|(objectclass=*)(objectclass=nsTombstone))'
serverctrls = [TestCtrl()]
ents = m1.search_s(basedn, scope, filter)
print "search returned %d entries" % len(ents)
print "send abandon with controls . . ."
m1.abandon_ext(999, serverctrls)
print "send abandon without controls . . ."
msgid2 = m1.abandon_ext(999)
print "send unbind with controls . . ."
# for some reason, unbind_ext_s is not passing
# controls passed in - so have to set_option
m1.set_option(ldap.OPT_SERVER_CONTROLS, serverctrls)
m1.unbind_ext_s(serverctrls)
print "try a search after the unbind . . ."
try:
    ents = m1.search_s(basedn, scope, filter)
except ldap.LDAPError, e:
    print "caught exception", e

print "open new connection . . ."
m1 = DSAdmin(host1, port1, binddn, bindpw)
print "show active connections . . ."
ents = m1.search_s("cn=monitor", ldap.SCOPE_BASE, '(objectclass=*)',
                   ['currentconnections', 'connection'])
for ent in ents:
    print ent
Пример #6
0
    'no_admin': True
})
#del os.environ['USE_DBX']

initfile = ''
if os.environ.has_key('SERVER_ROOT'):
    initfile = "%s/slapd-%s/ldif/Example.ldif" % (m1.sroot,m1.inst)
else:
    initfile = "%s/share/dirsrv/data/Example.ldif" % os.environ.get('PREFIX', '/usr')

m1.importLDIF(initfile, '', "userRoot", True)

#m1.setLogLevel(65535)
print "Add the filtered group entry with bogus filter"
dn = "cn=TestDynamicGroup,dc=example,dc=com"
ent = Entry(dn)
ent.setValues('description', "Dynamic test group")
ent.setValues('objectclass', 'top', 'groupofuniquenames', 'groupofurls')
ent.setValues('memberurl', 'ldap:///dc=example,dc=com??sub?(&(objectclass=person)(uid=scart*)')
#ent.cn = 'TestDynamicGroup'
m1.add_s(ent)

print "Add the bogus aci for that group"
addmod = [(ldap.MOD_REPLACE, 'aci', '(targetattr = "*") (version 3.0;acl "Test Crash ACL";allow (all)(groupdn = "ldap:///cn=TestDynamicGroup,dc=example,dc=com");)')]
m1.modify_s("dc=example,dc=com", addmod)
#m1.setLogLevel(0)

print "Do a search binding as a member of the group"
conn = DSAdmin(host1, port1, "uid=scarter,ou=people,dc=example,dc=com", "sprain")
entries = conn.search_s("uid=scarter,ou=people,dc=example,dc=com", ldap.SCOPE_BASE, "objectclass=*");
Пример #7
0
print "Add user", ent.dn
ds.add_s(ent)
dn2 = ent.dn

dn = "cn=testgroup," + usersubtree + "," + suffix
ent = Entry(dn)
ent.setValues('objectclass', ['top', 'groupOfUniqueNames', 'ntgroup'])
ent.setValues('uniquemember', [dn1, dn2])
ent.setValues('ntUserDomainId', 'testgroup')
ent.setValues('ntGroupCreateNewGroup', 'true')
print "Add group", ent.dn
ds.add_s(ent)

print "modify", dn2
mod = [(ldap.MOD_ADD, 'description', 'a description')]
ds.modify_s(dn2, mod)

print "Wait for the magic to happen . . ."
time.sleep(5)
print "repl status:", ds.getReplStatus(agmtdn)

print "AD testuser6 entry:"
ents = ad.search_s(suffix, scope, "(samaccountname=testuser6)")
print ents[0]
print "AD testuser7 entry:"
ents = ad.search_s(suffix, scope, "(samaccountname=testuser7)")
print ents[0]
print "AD testgroup entry:"
ents = ad.search_s(suffix, scope, "(samaccountname=testgroup)")
print ents[0]