From ef5f8fbf67a605472a1f3a6cea546b15a18a9881 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Tue, 10 Jan 2012 14:00:16 -0500 Subject: [PATCH] More robust identity value handling for LDAP tooling Signed-off-by: Dan Scott --- tools/patron-load/ldap_osrf_sync | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tools/patron-load/ldap_osrf_sync b/tools/patron-load/ldap_osrf_sync index ff7caf2759..04fef38964 100755 --- a/tools/patron-load/ldap_osrf_sync +++ b/tools/patron-load/ldap_osrf_sync @@ -94,7 +94,7 @@ class User: self.home_ou = self.get_home_ou() self.first_given_name = self._simple_map('givenName') if not self.first_given_name: - self.first_given_name('LDAP_NULL') + self.first_given_name = 'LDAP_NULL' print >> sys.stderr, 'No givenName for %s' % (self.usrname) self.lang_pref = self._simple_map('preferredLanguage') @@ -137,15 +137,21 @@ class User: print >> sys.stderr, 'No lulColleagueId for %s' % (self.ldap_atts) return 2, 'NO_COLLEAGUE_ID' - ident_value = self.ldap_atts['lulColleagueId'][0].strip().lower() - if len(ident_value) != 7: - print >> sys.stderr, 'Datatel number not 7 chars for %s (%s)' % ( - self.usrname, ident_value + ident_value = self._simple_map('lulColleagueId') + if ident_value is None: + print >> sys.stderr, 'No Datatel number for %s (%s)' % ( + self.usrname ) - if len(ident_value) == 6: - ident_value = '0%s' % ident_value - elif len(ident_value) == 5: - ident_value = '00%s' % ident_value + else: + ident_value = ident_value.lower() + if len(ident_value) != 7: + print >> sys.stderr, 'Datatel number not 7 chars for %s (%s)' % ( + self.usrname, ident_value + ) + if len(ident_value) == 6: + ident_value = '0%s' % ident_value + elif len(ident_value) == 5: + ident_value = '00%s' % ident_value return 2, ident_value @@ -166,6 +172,7 @@ class User: 'student': 113, 'gr': 112, 'al': 114, + 'alumni': 114, 'faculty': 111, 'staff': 115, 'thorneloe': 115, -- 2.11.0