More robust identity value handling for LDAP tooling
authorDan Scott <dscott@laurentian.ca>
Tue, 10 Jan 2012 19:00:16 +0000 (14:00 -0500)
committerDan Scott <dscott@laurentian.ca>
Tue, 7 May 2013 18:57:27 +0000 (14:57 -0400)
Signed-off-by: Dan Scott <dscott@laurentian.ca>
tools/patron-load/ldap_osrf_sync

index ff7caf2..04fef38 100755 (executable)
@@ -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,