Skip to content

Commit

Permalink
🔊 Add error messages if adding users fails
Browse files Browse the repository at this point in the history
  • Loading branch information
jemrobinson committed Sep 13, 2023
1 parent ebe2bc0 commit 770d32f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion data_safe_haven/commands/admin_register_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def admin_register_users(
msg = "SRE name must be specified."
raise DataSafeHavenError(msg)
LoggingSingleton().info(
f"Preparing to register {len(usernames)} users with SRE '{sre_name}'"
f"Preparing to register {len(usernames)} user(s) with SRE '{sre_name}'"
)

# Load GraphAPI as this may require user-interaction that is not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ param (

# Find SRE security group
$SREGroup = Get-ADGroup -Filter "Name -eq 'Data Safe Haven SRE $SREName Users'" | Where-Object { $_.DistinguishedName -like '*Data Safe Haven Security Groups*' } | Select-Object -First 1
if (-not $SREGroup) {
Write-Output "ERROR: No user group found on the domain controller for SRE '[green]$SREName[/]'."
}

# Load usernames
$Usernames = ([Text.Encoding]::Utf8.GetString([Convert]::FromBase64String($UsernamesB64))).Split()
if (-not $Usernames) {
Write-Output "ERROR: No usernames provided to add to SRE '[green]$SREName[/]'."
}

# Add each user to the SRE group
if ($SREGroup -and $Usernames) {
Expand Down

0 comments on commit 770d32f

Please sign in to comment.