--- C:\Documents and Settings\William\My Documents\plugins.py-orig +++ C:\Documents and Settings\William\My Documents\plugins.py-flatten @@ -184,9 +199,16 @@ try: environ['repoze.who.logger'].debug('LDAP-MD in for loop.') for (dn, attributes) in self.ldap_connection.search_s(*args): + # Flatten single-element lists. + for k in attributes.keys(): + if len(attributes[k]) == 1: + attributes[k] = attributes[k][0] + environ['repoze.who.logger'].debug('LDAP-MD updating: %s.' % attributes) identity.update(attributes) + environ['repoze.who.logger'].debug('LDAP-MD done.') + except ldap.LDAPError, msg: environ['repoze.who.logger'].warn('Cannot add metadata: %s' % \ msg)