From bba89e4577269676f5e6ef6f2936685d4299087c Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Fri, 2 Sep 2011 08:54:19 -0400 Subject: [PATCH] What we _actually_ ran for the first load of student data Signed-off-by: Dan Scott --- tools/patron-load/ldap_sync | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tools/patron-load/ldap_sync b/tools/patron-load/ldap_sync index 0b7e8961da..0cff2c9c90 100644 --- a/tools/patron-load/ldap_sync +++ b/tools/patron-load/ldap_sync @@ -265,9 +265,10 @@ def update_existing_users(): UPDATE actor.usr SET home_ou = su.home_ou, - usrname = LOWER(su.usrname), + usrname = LOWER(su.email), profile = su.profile, - email = LOWER(su.email) + email = LOWER(su.email), + expire_date = '2012-09-30'::date FROM scratchpad.usr_staging su WHERE su.ident_value= actor.usr.ident_value AND su.profile IS NOT NULL @@ -303,7 +304,7 @@ def insert_new_users(): WHERE profile IS NULL; INSERT INTO actor.usr (usrname, passwd, email, first_given_name, family_name, home_ou, ident_type, ident_value, profile, expire_date) - SELECT LOWER(usrname), MD5(RANDOM()::TEXT), LOWER(email), first_given_name, family_name, home_ou, 2, ident_value, profile, '2012-09-30'::date + SELECT LOWER(email), MD5(RANDOM()::TEXT), LOWER(email), first_given_name, family_name, home_ou, 2, ident_value, profile, '2012-09-30'::date FROM scratchpad.usr_staging WHERE ident_value IN ( SELECT ident_value FROM scratchpad.usr_staging @@ -338,7 +339,7 @@ def search_for_students(con, attributes, create_date): search_scope = ldap.SCOPE_SUBTREE ldap_filter = '(&(objectclass=lulEduPerson))' ldap_filter = '(&(objectclass=lulEduPerson)(lulPrimaryAffiliation=*)(createTimestamp>=%s000000Z))' % create_date - ldap_filter = '(&(lulStudentLevel=*)(createTimestamp>=%s000000Z))' % create_date + ldap_filter = '(&(lulStudentLevel=*))' try: result_id = con.search(base_dn, search_scope, ldap_filter, attributes) @@ -366,9 +367,14 @@ def insert_into_staging(result_data): usrname = result_data['cn'][0].strip() email = result_data['mail'][0].strip() family_name = result_data['sn'][0].strip() - given_name = result_data['givenName'][0].strip() datatel = result_data['lulColleagueId'][0].strip() + if 'givenName' in result_data: + given_name = result_data['givenName'][0].strip() + else: + given_name = 'LDAP_NULL' + print >> sys.stderr, 'No givenName for %s' % (usrname) + if len(datatel) != 7: print >> sys.stderr, 'Datatel number not 7 chars for %s (%s)' % (usrname, datatel) if len(datatel) == 6: -- 2.11.0