summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Vagelpohl <jens@netz.ooo>2001-10-09 00:37:51 +0000
committerJens Vagelpohl <jens@netz.ooo>2001-10-09 00:37:51 +0000
commit809c37e8907f3eb66ceb56956d31ccbf286a9a33 (patch)
treebac31db984ae591ee11c88826ecd7e27723d8bb3
parentc20d8c902f46076b11dda32272f2516040e18e85 (diff)
downloadLDAPLoginAdapter-809c37e8907f3eb66ceb56956d31ccbf286a9a33.zip
LDAPLoginAdapter-809c37e8907f3eb66ceb56956d31ccbf286a9a33.tar.gz
Changes suggested by Brad Clements:
- wrap unicode-to-latin1 conversion in try/except (NDS likes to return spurious binar y data) - guard getGroups against an empty CN field when the group query returns (another NDS quirk)
-rw-r--r--LDAPShared.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/LDAPShared.py b/LDAPShared.py
index 1f20aec..c5e693d 100644
--- a/LDAPShared.py
+++ b/LDAPShared.py
@@ -140,8 +140,11 @@ class LDAPShared:
for rec_dn, rec_dict in res:
for key, value in rec_dict.items():
- for i in range(len(value)):
- value[i] = self.utf8_to_latin1(value[i])
+ try:
+ for i in range(len(value)):
+ value[i] = self.utf8_to_latin1(value[i])
+ except:
+ pass
except _ldap.NO_SUCH_OBJECT:
res = '###ERROR###: Cannot find %s under %s!' % (
@@ -269,12 +272,18 @@ class LDAPShared:
group_list = (res,)
elif len(res) > 0:
for i in range(len(res)):
+ dn = res[i][0]
+ try:
+ cn = res[i][1]['cn'][0]
+ except KeyError: # Novell Directory Server oddity
+ cn = _ldap.explode_dn( dn, 1 )[0]
+
if attr is None:
- group_list.append((res[i][1]['cn'][0], res[i][0]))
+ group_list.append( ( cn, dn ) )
elif attr == 'cn':
- group_list.append(res[i][1]['cn'][0])
+ group_list.append( cn )
elif attr == 'dn':
- group_list.append(res[i][0])
+ group_list.append( dn )
return group_list