Example #1
0
obj = ObjectProxy(u"cn=Claudia Mustermann,ou=people,dc=gonicus,dc=de")
et = obj.get_extension_types()
if 'PosixUser' in et and not et['PosixUser']:
    obj.extend('PosixUser')
    obj.homeDirectory = '/home/' + obj.uid
    obj.gidNumber = 4711
    obj.commit()
else:
    obj.retract('PosixUser')

print "*" * 80
print "Search"
print "*" * 80

for entry in ie.search(base=u"dc=gonicus,dc=de", scope=SCOPE_SUB, fltr={'sn': u'Mustermann'}, attrs=['_dn']):
    obj = ObjectProxy(entry['_dn'])
    print "* Found", obj.dn
    print "  Parent DN:", obj.get_parent_dn()
    print "  Type:", obj.get_base_type()
    print "  Extensions:", ", ".join(e for e, i in obj.get_extension_types().items() if i)
    print "  Given name:", obj.givenName
    print "  Last name:", obj.sn

# Do a modification
if 1 == 1:
    obj = ObjectProxy(u"cn=Claudia Mustermann,ou=people,dc=gonicus,dc=de")
    obj.roomNumber = "19b"
    obj.givenName = u"Günter"
    #obj.notify("Wichtige Nachricht", u"Hallo Günter - alles wird gut!")
    obj.commit()
Example #2
0
if args.scope == "sub":
    scope = SCOPE_SUB
if args.scope == "one":
    scope = SCOPE_ONE
if args.scope == "base":
    scope = SCOPE_BASE
if not scope:
    print "Error: invalid scope"
    exit(1)

sys.argv = [sys.argv[0]]
ie = ObjectIndex()

# Test synchronisation
if args.sync:
    print "Please wait - updating index..."
    ie.sync_index()

start = stop = None
if args.offset and args.count:
    start = args.offset
    stop = args.ofset + args.count - 1

for e in ie.search(base=args.base, scope=scope, fltr=fltr, attrs=args.attrs,
        begin=start, end=stop):
    print e
exit(0)


print "\nCount:", ie.count(base="dc=gonicus,dc=de", fltr=fltr)