0002-ldap_backend-detect-failure-to-create-a-username-194.patch
src/authentic2/backends/ldap_backend.py | ||
---|---|---|
459 | 459 |
def create_username(self, block, attributes): |
460 | 460 |
'''Build a username using the configured template''' |
461 | 461 |
username_template = unicode(block['username_template']) |
462 |
return username_template.format(realm=block['realm'], |
|
463 |
**attributes) |
|
462 |
try: |
|
463 |
return username_template.format(realm=block['realm'], **attributes) |
|
464 |
except KeyError as e: |
|
465 |
log.warning('missing attribute %s to build the username', e.args[0]) |
|
466 |
# attributes are missing to build the username |
|
467 |
return None |
|
464 | 468 | |
465 | 469 |
def populate_user_attributes(self, user, block, attributes): |
466 | 470 |
for legacy_attribute, legacy_field in (('email', 'email_field'), |
... | ... | |
801 | 805 |
return |
802 | 806 |
log.debug('retrieved attributes for %r: %r', dn, attributes) |
803 | 807 |
username = self.create_username(block, attributes) |
808 |
if not username: |
|
809 |
return |
|
804 | 810 |
return self._return_django_user(dn, username, password, conn, block, attributes) |
805 | 811 | |
806 | 812 |
def _return_django_user(self, dn, username, password, conn, block, attributes): |
807 |
- |