Skip to content
Snippets Groups Projects
Commit 377edce0 authored by Hague Matthew UXAC009's avatar Hague Matthew UXAC009
Browse files

Allow for varying prog mailing list formats in LDAP

parent a1530fd9
Branches
No related tags found
No related merge requests found
......@@ -6,7 +6,10 @@ import os
import subprocess
import sys
PROG_FILTER = "(memberOf=CN=MG_STU_DPDEDY_CS_{}_{},OU=programme-by-year,OU=dept,OU=student,OU=Distribution Lists,OU=MIIS Managed,DC=cc,DC=rhul,DC=local)"
PROG_FILTERS = [
"(memberOf=CN=MG_STU_DPDEDY_CS_{}_{},OU=programme-by-year,OU=dept,OU=student,OU=Distribution Lists,OU=MIIS Managed,DC=cc,DC=rhul,DC=local)",
"(memberOf=CN=MG_STU_DPDEDY_CS_{}_{},OU=system,OU=Distribution Lists,OU=MIIS Managed,DC=cc,DC=rhul,DC=local)"
]
PROG_TITLES = {
"1067": "BSc Computer Science",
......@@ -77,20 +80,21 @@ with ldap3.Connection(URI,
password=password,
authentication=ldap3.SIMPLE) as conn:
for code in prog_codes:
prog_filter = PROG_FILTER.format(code, stage)
conn.search(BASE, prog_filter, attributes=student_attrs)
for filter_fmt in PROG_FILTERS:
prog_filter = filter_fmt.format(code, stage)
conn.search(BASE, prog_filter, attributes=student_attrs)
title = PROG_TITLES[code]
count = 0
for student in conn.entries:
count += 1
writer.writerow([
code,
title,
count,
student.displayName,
student.extensionAttribute3,
student.mail,
student.extensionAttribute2
])
title = PROG_TITLES[code]
count = 0
for student in conn.entries:
count += 1
writer.writerow([
code,
title,
count,
student.displayName,
student.extensionAttribute3,
student.mail,
student.extensionAttribute2
])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment