fix first/last name script
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Max Erenberg 2021-11-07 01:12:49 -04:00
parent ed9893604f
commit 798510511f
1 changed files with 3 additions and 6 deletions

View File

@ -30,15 +30,12 @@ for csc_entry in csc_conn.entries:
cn = csc_entry.cn.value cn = csc_entry.cn.value
sn = None sn = None
given_name = None given_name = None
try: uw_conn.search(
uw_conn.search( UWLDAP_MEMBERS_BASE, f'(uid={uid})', attributes=['sn', 'givenName'])
f'uid={uid},{UWLDAP_MEMBERS_BASE}', '(objectClass=*)', if uw_conn.entries:
attributes=['sn', 'givenName'], search_scope=ldap3.BASE)
uw_entry = uw_conn.entries[0] uw_entry = uw_conn.entries[0]
sn = uw_entry.sn.value sn = uw_entry.sn.value
given_name = uw_entry.givenName.value given_name = uw_entry.givenName.value
except ldap3.core.exceptions.LDAPNoSuchObjectResult:
pass
if given_name is None or sn is None: if given_name is None or sn is None:
print(f'WARNING: could not retrieve first and last names for {uid}; inferring from whitespace instead') print(f'WARNING: could not retrieve first and last names for {uid}; inferring from whitespace instead')
words = cn.split() words = cn.split()