Home Documentation Software Old Stuff

LDAPUserFolder: Small error in LDAPUserFolder.getUserByAttr() (Resolved)

Request LDAP User Folder -- bug report -- by Martin Gfeller, COMIT AG
Posted on Apr 17, 2008 8:03 am

Enter your email address to receive mail on every change to this issue.

Entries (Latest first)

  Resolve by Jens Vagelpohl on Apr 17, 2008 8:26 am
  Thanks for the bug report, I fixed it by providing an explicit default:


  Initial Request by Martin Gfeller, COMIT AG on Apr 17, 2008 8:03 am

I'm getting an len() of unsized object error in LDAPUserFolder 2.7, but the problem code seems to be in 2.9.beta as well, so I'd like to bring it to your attention.

In LDAPUserFolder.getUserByAttr(), Line 694ff, login_name is defaulted to None by the .get(), but a few lines later on, a len() is done on it, which fails if it is None.
I have no idea why not user_attrs.has_key(self._login), but the default handling is certainly wrong.

>>> login_name = user_attrs.get(self._login_attr)
uid = user_attrs.get(self._uid_attr)

>>> if self._login_attr != 'dn' and len(login_name) > 0:
if name == self._login_attr:
logins = [x for x in login_name if value.lower() == x.lower()]
login_name = logins[0]
login_name = login_name[0]
>>> elif len(login_name) == 0:
msg = 'getUserByAttr: "%s" has no "%s" (Login) value!' % (
user_dn, self._login_attr
self._cache('negative').set(value, NonexistingUser())
return None

I'd like to take the opportunity and thank you for a very useful product!

Best regards,
Martin Gfeller