"""
if len(barcode) != 14:
- return false
+ return False
return barcode[6:13]
WHEN LOWER(email) LIKE '%huntingtonu.ca' THEN 104
END,
profile = CASE
+ WHEN LOWER(affiliation) = 'gr' THEN 12
+ WHEN LOWER(affiliation) = 'ug' THEN 13
WHEN LOWER(affiliation) = 'faculty' THEN 11
WHEN LOWER(affiliation) = 'student' THEN 13
WHEN LOWER(affiliation) = 'staff' THEN 15
END
;
- UPDATE actor.usr SET
- home_ou = su.home_ou,
- usrname = LOWER(su.usrname),
- profile = su.profile,
- email = LOWER(su.email),
- first_given_name = su.first_given_name,
- family_name = su.family_name
- FROM scratchpad.usr_staging su
- WHERE su.ident_value= actor.usr.ident_value
- AND actor.usr.home_ou IN (
- SELECT id FROM actor.org_unit WHERE parent_ou = 105
- )
- AND su.profile IS NOT NULL
+ UPDATE actor.usr
+ SET home_ou = su.home_ou,
+ usrname = LOWER(su.usrname),
+ profile = su.profile,
+ email = LOWER(su.email)
+ FROM scratchpad.usr_staging su
+ WHERE su.ident_value= actor.usr.ident_value
+ AND su.profile IS NOT NULL
+ AND actor.usr.home_ou IN (
+ SELECT id FROM actor.org_unit WHERE parent_ou = 105
+ )
;
UPDATE scratchpad.usr_staging
SET profile = 13
WHERE profile IS NULL;
- INSERT INTO actor.usr (usrname, passwd, email, first_given_name, family_name, home_ou, ident_type, ident_value, profile)
- SELECT LOWER(usrname), MD5(RANDOM()::TEXT), LOWER(email), first_given_name, family_name, home_ou, 2, ident_value, profile
+ 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
FROM scratchpad.usr_staging WHERE ident_value IN (
SELECT ident_value
FROM scratchpad.usr_staging
"""
def search_for_students(con, attributes, create_date):
+ """
+ Retrieve personnel accounts from LDAP directory and process'em
+ """
base_dn = 'o=lul'
search_scope = ldap.SCOPE_SUBTREE
- filter = '(&(objectclass=lulEduPerson))'
- filter = '(&(objectclass=lulEduPerson)(lulPrimaryAffiliation=*)(createTimestamp>=%s000000Z))' % create_date
+ ldap_filter = '(&(objectclass=lulEduPerson))'
+ ldap_filter = '(&(objectclass=lulEduPerson)(lulPrimaryAffiliation=*)(createTimestamp>=%s000000Z))' % create_date
+ ldap_filter = '(&(lulStudentLevel=*)(createTimestamp>=%s000000Z))' % create_date
try:
- result_id = con.search(base_dn, search_scope, filter, attributes)
- result_set = []
+ result_id = con.search(base_dn, search_scope, ldap_filter, attributes)
while 1:
result_type, result_data = con.result(result_id, 0)
if result_data == []:
if len(datatel) != 7:
print >> sys.stderr, 'Datatel number not 7 chars for %s (%s)' % (usrname, datatel)
- return
+ if len(datatel) == 6:
+ datatel = '0%s' % datatel
+ elif len(datatel) == 5:
+ datatel = '00%s' % datatel
if 'preferredLanguage' in result_data:
lang = result_data['preferredLanguage'][0].strip()
else:
lang = r'\N'
- if 'lulPrimaryAffiliation' in result_data:
+ if 'lulStudentLevel' in result_data:
+ affiliation = result_data['lulStudentLevel'][0].strip()
+ elif 'lulPrimaryAffiliation' in result_data:
affiliation = result_data['lulPrimaryAffiliation'][0].strip()
else:
affiliation = r'\N'
print(create_staging_table())
try:
- attributes = ['lulPrimaryAffiliation', 'cn', 'mail', 'givenName', 'sn', 'lulColleagueId', 'preferredLanguage']
+ attributes = ['lulStudentLevel', 'lulPrimaryAffiliation', 'cn', 'mail', 'givenName', 'sn', 'lulColleagueId', 'preferredLanguage']
con.simple_bind_s(luauth.dn, luauth.pw)
search_for_students(con, attributes, create_date)
except ldap.LDAPError, e: