From: Dan Scott Date: Wed, 7 Aug 2019 21:12:39 +0000 (-0400) Subject: Be really strict about invalid lulColleagueId values X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6484de2338fa7bb642f9f82b66c48b9ccd85e5fd;p=contrib%2FConifer.git Be really strict about invalid lulColleagueId values Signed-off-by: Dan Scott --- diff --git a/tools/patron-load/ldap_osrf_sync b/tools/patron-load/ldap_osrf_sync index c91500a8ea..be337ffe88 100755 --- a/tools/patron-load/ldap_osrf_sync +++ b/tools/patron-load/ldap_osrf_sync @@ -154,27 +154,19 @@ 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._simple_map('lulColleagueId') if ident_value is None: - print >> sys.stderr, 'No Datatel number for %s (%s)' % ( - self.usrname - ) + print >> sys.stderr, 'No lulColleagueId for %s' % (self.ldap_atts) + return 2, 'NO_COLLEAGUE_ID' 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 + if len(ident_value) == 7 and ident_value[0] == '0': + return 2, ident_value - return 2, ident_value + print >> sys.stderr, 'Invalid lulColleagueId number for %s (%s)' % ( + self.usrname, ident_value + ) + return 2, 'INVALID_COLLEAGUE_ID' def get_profile(self): """ @@ -358,8 +350,8 @@ def find_ldap_users(con, ldap_filter, attributes, auth): if ARGS.dump_ldap: dump_data(raw_atts) print("dn = '%s'" % (raw_user)) - if user.ident_value == 'NO_COLLEAGUE_ID': - print >> sys.stderr, "No colleague ID: skipping" + if user.ident_value in ('NO_COLLEAGUE_ID', 'INVALID_COLLEAGUE_ID'): + print >> sys.stderr, "Missing or invalid colleague ID: skipping" continue if ARGS.create_users: res = create_evergreen_user(auth, user) @@ -379,8 +371,11 @@ def find_ldap_users(con, ldap_filter, attributes, auth): print >> sys.stderr, "User not found in Evergreen: %s" % \ (user.ident_value) continue - user.barcode = get_barcode(auth, uid) - update_ldap_barcode(con, user) + try: + user.barcode = get_barcode(auth, uid) + update_ldap_barcode(con, user) + except AttributeError: + continue except ldap.LDAPError, exc: print >> sys.stderr, exc