Split entries from LDAP
paul
paul at subsignal.org
Sun Oct 12 16:07:33 EDT 2008
Lars schrieb:
> I got all the entries in the variable "raw_res" and I now got some
> doubts on how to split each value up in every entry. Belove you can
> see one of entries printed from the loop.
> cn=world.dom.dk,ou=Hosts,o=Users,dc=dom,dc=dk', {'ipHostNumber':
> ['192.168.0.43'], 'cn': ['world.dom.dk'], 'description':
> ['Mail&webserver']})"
>
> I've tried different things, but don't quite know to split the tuple.
search_s() returns a tuple of lenght 2. The first entry is the DN, the
second entry is a dictionary with attributes as keys and lists of values
as values. Possible function to handle this (untested):
def print_entry(entry):
print "Got Entry for DN: %s" % entry[0]
print "Attributes:"
for key, value in entry[1].items():
print "\tKey: %s" % key
print "\tValue(s): %s" ", ".join(value)
print
the ", ".join(value) creates a string from a list, check the docs for
dictionaries for other syntax elements.
cheers
Paul
More information about the Python-list
mailing list