|
|
|
@ -316,12 +316,12 @@ class LDAPService: |
|
|
|
|
self, |
|
|
|
|
dry_run: bool = False, |
|
|
|
|
members: Union[List[str], None] = None, |
|
|
|
|
uwldap_batch_size: int = 10, |
|
|
|
|
uwldap_batch_size: int = 100, |
|
|
|
|
): |
|
|
|
|
if members: |
|
|
|
|
filter = '(|' + ''.join([f'(uid={uid})' for uid in members]) + ')' |
|
|
|
|
else: |
|
|
|
|
filter = '(objectClass=*)' |
|
|
|
|
filter = '(objectClass=member)' |
|
|
|
|
conn = self._get_ldap_conn() |
|
|
|
|
conn.search( |
|
|
|
|
self.ldap_users_base, filter, attributes=['uid', 'program']) |
|
|
|
@ -336,12 +336,17 @@ class LDAPService: |
|
|
|
|
batch_uids = uids[i:i + uwldap_batch_size] |
|
|
|
|
batch_uw_programs = uwldap_srv.get_programs_for_users(batch_uids) |
|
|
|
|
uw_programs.extend(batch_uw_programs) |
|
|
|
|
# uw_programs[i] will be None if the 'ou' attribute was not |
|
|
|
|
# present in UWLDAP, or if no UWLDAP entry was found at all |
|
|
|
|
for i, uw_program in enumerate(uw_programs): |
|
|
|
|
if uw_program in (None, 'expired', 'orphaned'): |
|
|
|
|
# If the UWLDAP record is orphaned, nonexistent, or missing |
|
|
|
|
# data, assume that the member graduated |
|
|
|
|
uw_programs[i] = 'Alumni' |
|
|
|
|
users_to_change = [ |
|
|
|
|
(uids[i], csc_programs[i], uw_programs[i]) |
|
|
|
|
for i in range(len(uids)) |
|
|
|
|
if csc_programs[i] != uw_programs[i] and ( |
|
|
|
|
uw_programs[i] not in (None, 'expired', 'orphaned') |
|
|
|
|
) |
|
|
|
|
if csc_programs[i] != uw_programs[i] |
|
|
|
|
] |
|
|
|
|
if dry_run: |
|
|
|
|
return users_to_change |
|
|
|
|