Error modlist.py in addModlist

Michael Ströder michael at stroeder.com
Tue Mar 20 20:04:08 CET 2007


Garland, Ken R wrote:
>                 entry = "{'uid': ['" + uid + "'], 'objectClass':
> ['top', 'inetOrgPerson'], 'userPassword': ['" + '{SHA}' + userpass +
> "'], 'vamc': ['" + vamcdrop + "'], 'sn': ['" + lastname + "'],
> 'givenName': ['" + firstname + "'], 'cn': ['" + firstname + " " +
> lastname + "']}"

What made you think that you have to pass a string for parameter
'entry'? It MUST be a dictionary. As others noted all attribute values
should be encoded to strings. This can either require .encode('utf-8')
or .encode('ascii') according to the LDAP syntax defined for
the various attributes.
(One might argue that UTF-8 is a superset of ASCII but IMO it's better
to catch syntax errors before sending anything to the server.)

> {'uid': ['null.null'], 'objectClass': ['top', 'inetOrgPerson'],
> 'userPassword': ['{SHA}null'], 'vamc': ['null'], 'sn': ['null'],
> 'givenName': ['null'], 'cn': ['null null']}

BTW: Setting pseudo-null values is bad practice when adding LDAP
entries. You may run into interop issues with other LDAP-enabled
applications later.

Ciao, Michael.





More information about the python-ldap mailing list