Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rhul-scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Whyte Cameron (2023) ZMAC302
rhul-scripts
Commits
377edce0
Commit
377edce0
authored
2 years ago
by
Hague Matthew UXAC009
Browse files
Options
Downloads
Patches
Plain Diff
Allow for varying prog mailing list formats in LDAP
parent
a1530fd9
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ldap/rhul-programme-info.py
+20
-16
20 additions, 16 deletions
ldap/rhul-programme-info.py
with
20 additions
and
16 deletions
ldap/rhul-programme-info.py
+
20
−
16
View file @
377edce0
...
...
@@ -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
])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment