Modify ↓
      
        Opened 11 years ago
Closed 10 years ago
#12157 closed defect (fixed)
LdapAuthStorePlugin dies on login with exceptions.KeyError when LDAP Attribute is not present (name or email)
| Reported by: | Owned by: | igoltz | |
|---|---|---|---|
| Priority: | high | Component: | LdapAuthStorePlugin | 
| Severity: | critical | Keywords: | |
| Cc: | steinbach.till@… | Trac Release: | 1.0 | 
Description
When the attributes specified for name and mail are not available in the response of the server when obtaining the user the script dies with exceptions.KeyError in ldap_store.py:
# Store values from ldap in the session cache
for attr in ('name', 'email'):
    if not attrs[attr]:
        continue
    value = unicode(attrs[attr], 'utf-8')
if required I can provide the sequence of function calls leading up to the error.
Versions:
- Trac 1.0.3
 - LdapAuthStorePlugin 0.3.1
 - LdapPlugin 0.7.0dev-r0
 
Attachments (0)
Change History (5)
comment:3 Changed 11 years ago by
Should we commit the change? Let me know, I would be happy to commit it.
comment:4 Changed 11 years ago by
I have tested that with one user, only. We are currently moving a trac with a lot of users to LDAP, let me see if that goes well first!
Note: See
        TracTickets for help on using
        tickets.
    


I not anymore have the infrastructure to run the plugin, so I can't test it. But you could try this change. Just above your code excerpt a block like this is found
Change to this, adding
attrs['XXX'] = ''after each exceptattrs = {} try: attrs['name'] = result[0][1][self.ldap_name_attr][0] except: attrs['name'] = '' self.log.warn('Attribute %s not found in %s' % (self.ldap_name_attr, dn.decode('iso-8859-15'))) try: attrs['email'] = result[0][1][self.ldap_email_attr][0] except: attrs['email'] = '' self.log.warn('Attribute %s not found in %s' % (self.ldap_email_attr, dn.decode('iso-8859-15')))