Пример #1
0
 def handle(self,dn,entry):
     if not dn:
         dn = ''
     newentry = Entry((dn, entry))
     if newentry.hasValueCase('objectclass', 'inetorgperson'):
         ocvals = newentry.getValues('objectclass')
         ocvals.append('inetUser')
         newentry.setValue('objectclass', ocvals)
     try: self.conn.add_s(newentry)
     except ldap.LDAPError, e:
         if not self.cont: raise e
         print "Error: could not add entry %s: error %s" % (dn, str(e))
Пример #2
0
 def handle(self, dn, entry):
     if not dn:
         dn = ''
     newentry = Entry((dn, entry))
     if newentry.hasValueCase('objectclass', 'inetorgperson'):
         ocvals = newentry.getValues('objectclass')
         ocvals.append('inetUser')
         newentry.setValue('objectclass', ocvals)
     try:
         self.conn.add_s(newentry)
     except ldap.LDAPError, e:
         if not self.cont: raise e
         print "Error: could not add entry %s: error %s" % (dn, str(e))
Пример #3
0
 def handle(self,dn,entry):
     """
     Append single record to dictionary of all records.
     """
     if not dn:
         dn = ''
     newentry = Entry((dn, entry))
     objclasses = newentry.getValues('objectclass')
     if 'inetOrgPerson' in objclasses:
         print "adding posixAccount to ", dn
         objclasses.append('posixAccount')
         objclasses.append('myintobjclass')
         newentry.setValue('objectclass', objclasses)
         newentry.setValue('uidNumber', str(self.uidNumber))
         newentry.setValue('gidNumber', str(self.uidNumber))
         newentry.setValue('homeDirectory', '/home/foo')
         newentry.setValue('myintattr', str(self.uidNumber))
         self.uidNumber = self.uidNumber + 1
     print>>self.output_file, str(newentry)
Пример #4
0
    ent.setValues('sn', 'testuser')
    svr = svrs[ii % nsvrs]
    svr.add_s(ent)
    print "Added %s to %s" % (dn, svr)

print "see if all entries are on both servers . . ."
time.sleep(5)
for ii in range(0,nents):
    dn = "cn=%d, %s" % (ii, basedn)
    ent = m1.getEntry(dn, ldap.SCOPE_BASE)
    ent = m2.getEntry(dn, ldap.SCOPE_BASE)

print """
Do add description, modify description, delete description to each entry alternately . . .
"""
dn = "cn=%d, %s" % (0, basedn)
for ii in range(0,100):
    descstr = "this is description %d" % ii
    modadd = [(ldap.MOD_ADD, 'description', descstr)]
    moddel = [(ldap.MOD_DELETE, 'description', descstr)]
    m1.modify_s(dn, modadd)
    time.sleep(1)
    m2.modify_s(dn, moddel)

ent = m1.getEntry(dn, ldap.SCOPE_BASE)
if ent.description:
    print "Error: m1 has description attribute: %s" % str(ent.getValues("description"))
ent = m2.getEntry(dn, ldap.SCOPE_BASE)
if ent.description:
    print "Error: m2 has description attribute: %s" % str(ent.getValues("description"))
Пример #5
0
    svr.add_s(ent)
    print "Added %s to %s" % (dn, svr)

print "see if all entries are on both servers . . ."
time.sleep(5)
for ii in range(0, nents):
    dn = "cn=%d, %s" % (ii, basedn)
    ent = m1.getEntry(dn, ldap.SCOPE_BASE)
    ent = m2.getEntry(dn, ldap.SCOPE_BASE)

print """
Do add description, modify description, delete description to each entry alternately . . .
"""
dn = "cn=%d, %s" % (0, basedn)
for ii in range(0, 100):
    descstr = "this is description %d" % ii
    modadd = [(ldap.MOD_ADD, 'description', descstr)]
    moddel = [(ldap.MOD_DELETE, 'description', descstr)]
    m1.modify_s(dn, modadd)
    time.sleep(1)
    m2.modify_s(dn, moddel)

ent = m1.getEntry(dn, ldap.SCOPE_BASE)
if ent.description:
    print "Error: m1 has description attribute: %s" % str(
        ent.getValues("description"))
ent = m2.getEntry(dn, ldap.SCOPE_BASE)
if ent.description:
    print "Error: m2 has description attribute: %s" % str(
        ent.getValues("description"))
Пример #6
0
    ent.setValues('sn', 'testuser')
    svr = svrs[ii % nsvrs]
    svr.add_s(ent)
    print "Added %s to %s" % (dn, svr)

print "see if all entries are on both servers . . ."
time.sleep(5)
for ii in range(0,nents):
    dn = "cn=%d, %s" % (ii, basedn)
    ent = m1.getEntry(dn, ldap.SCOPE_BASE)
    ent = m2.getEntry(dn, ldap.SCOPE_BASE)

print """
Do add description, modify description, delete description to each entry alternately . . .
"""
dn = "cn=%d, %s" % (0, basedn)
for ii in range(0,100):
    descstr = "this is description %d" % ii
    modadd = [(ldap.MOD_ADD, 'description', descstr)]
    moddel = [(ldap.MOD_DELETE, 'description', descstr)]
    m1.modify_s(dn, modadd)
    time.sleep(1)
    m2.modify_s(dn, moddel)

ent = m1.getEntry(dn, ldap.SCOPE_BASE)
if ent.description:
    print "Error: m1 has description attribute: %s" % str(ent.getValues("description"))
ent = m2.getEntry(dn, ldap.SCOPE_BASE)
if ent.description:
    print "Error: m2 has description attribute: %s" % str(ent.getValues("description"))