Skip to content

Commit

Permalink
Merge pull request #24 from IT-CEREBRUM/CRB-4005-feide-ldif-eduperson…
Browse files Browse the repository at this point in the history
…uniqueid

Revert "Revert "Add eduPersonUniqueID identifier""
  • Loading branch information
Christina Skåre Nordtømme authored and GitHub Enterprise committed Feb 27, 2023
2 parents c485407 + f8f79ac commit 3de263a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cerebrum/Person.py
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ def list_persons(self, person_id=None):
where = 'WHERE ' + argument_to_sql(person_id, 'person_id',
binds, int)
return self.query("""
SELECT person_id, birth_date
SELECT person_id, birth_date, export_id
FROM [:table schema=cerebrum name=person_info]
""" + where, binds)

Expand Down
17 changes: 17 additions & 0 deletions Cerebrum/modules/OrgLDIF.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ def init_person_dump(self, use_mail_module):
self.init_person_cache()
self.init_person_affiliations()
self.init_person_names()
self.init_export_ids()
self.init_person_titles()
self.init_person_addresses()
self.init_person_aliases()
Expand Down Expand Up @@ -627,6 +628,16 @@ def init_person_names(self):
person_names[person_id][int(row['name_variant'])] = row['name']
timer("...personal names done.")

def init_export_ids(self):
# Set self.export_ids = dict {person_id: {export_id: id}}
timer = make_timer(logger, "Fetching export ids...")
self.export_ids = export_ids = defaultdict()
for row in self.person.list_persons():
person_id = int(row['person_id'])
export_id = row["export_id"]
export_ids[person_id] = export_id
timer("... export ids done.")

def init_person_titles(self):
# Set self.person_titles = dict {person_id: [(language,title),...]}
timer = make_timer(logger, "Fetching personal titles...")
Expand Down Expand Up @@ -992,6 +1003,12 @@ def make_person_entry(self, row, person_id):
if primary_ou_dn:
entry['eduPersonPrimaryOrgUnitDN'] = (primary_ou_dn,)

export_id = self.export_ids.get(person_id)
if export_id:
entry['eduPersonUniqueID'] = "@".join(
(export_id, self.config.domain_name)
)

edu_ous = self._calculate_edu_ous(
primary_ou_dn,
[self.ou2DN.get(aff[2]) for aff in p_affiliations])
Expand Down

0 comments on commit 3de263a

Please sign in to comment.