Skip to content

Commit

Permalink
Merge pull request #19 from MaastrichtUniversity/hotfix/DHS-1329
Browse files Browse the repository at this point in the history
Added rule for getting a user's e-mail AVU [DHS-1329]
  • Loading branch information
deanlinssen authored Mar 12, 2021
2 parents 59deedb + 6535b77 commit aedc545
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions misc/getEmailForAccount.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Call with
#
# irule -F getEmailForAccount.r "*account='mcoonen'"

irule_dummy() {
IRULE_getEmailForAccount(*account , *result);
writeLine("stdout", *result);
}

IRULE_getEmailForAccount(*account,*result) {
*userID = ""
*userEmail = ""

# Get the e-mail address given the username
foreach (*Row in SELECT META_USER_ATTR_VALUE, USER_ID WHERE USER_NAME == "*account" AND META_USER_ATTR_NAME == "email" ) {
*userEmail = *Row.META_USER_ATTR_VALUE
*userID = *Row.USER_ID
}
# If the userID is empty for this account, write rodsLog warning for missing irods account
# The value returned for this function is this the account name
if (*userID == "") {
msiWriteRodsLog("Warning: getting email address for unknown account: *account", 0);
}

# If the Display name is missing revert to the account name
if (*userEmail == "") {
*userEmail = *account
}

*result = *userEmail;
}

INPUT *account='mcoonen'
OUTPUT ruleExecOut

0 comments on commit aedc545

Please sign in to comment.