LDAP: More robust processing and error reporting
authorDan Scott <dscott@laurentian.ca>
Mon, 5 Dec 2011 16:44:30 +0000 (11:44 -0500)
committerDan Scott <dscott@laurentian.ca>
Tue, 7 May 2013 18:57:21 +0000 (14:57 -0400)
Don't die if we don't have an lulColleagueId; spit out the attributes
that we have ready at hand to help identify the problem record.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
tools/patron-load/ldap_osrf_sync

index eee82dd..4fb5a57 100755 (executable)
@@ -133,6 +133,10 @@ class User:
         Map LDAP record to Evergreen identity type and value
         """
 
+        if 'lulColleagueId' not in self.ldap_atts:
+            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)' % (
@@ -175,7 +179,7 @@ class User:
             return profile_map[affiliation]
         else:
             print >> sys.stderr, "Affiliation '%s' not mapped to a profile " \
-                "for user %s" % (affiliation, self.usrname)
+                "for user %s" % (affiliation, self.ldap_atts)
         return None
 
     def get_home_ou(self):