summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Vagelpohl <jens@netz.ooo>2001-10-09 00:37:24 +0000
committerJens Vagelpohl <jens@netz.ooo>2001-10-09 00:37:24 +0000
commit5458ef88ea8f6ff0c0159c8988025d39e611c73f (patch)
treec26a251ec8edf8ddb57ac1023c59cc78e42f301f
parent0b72b43f374e41729eb2c58bcad2af06ffcee63f (diff)
downloadLDAPUserManager-5458ef88ea8f6ff0c0159c8988025d39e611c73f.zip
LDAPUserManager-5458ef88ea8f6ff0c0159c8988025d39e611c73f.tar.gz
Changes suggested by Brad Clements:
- wrap unicode-to-latin1 conversion in try/except (NDS likes to return spurious binary data) - guard getGroups against an empty CN field when the group query returns (another NDS quirk)
-rw-r--r--LDAPShared.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/LDAPShared.py b/LDAPShared.py
index ac1c18b..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
@@ -329,7 +338,7 @@ class LDAPShared:
def manage_addLDAPSchemaItem(self, ldap_name, friendly_name='',
REQUEST=None):
""" Add a schema item to my list of known schema items """
- schema = self._ldapschema
+ schema = list( self._ldapschema )
schema.append((ldap_name, friendly_name))
self._ldapschema = schema