Skip to content

Commit

Permalink
Merge pull request #41 from JohnDuprey/dev
Browse files Browse the repository at this point in the history
Fix Aliases on DuoUser
  • Loading branch information
JohnDuprey authored Aug 30, 2024
2 parents 2e84e49 + d9a0dde commit 34c92bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
12 changes: 6 additions & 6 deletions DuoSecurity/Public/Admin API/Users/New-DuoUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function New-DuoUser {
The name of the user to create.
.PARAMETER Aliases
Username aliases for the user. Up to eight aliases may be specified with this parameter as a set of URL-encoded key-value pairs e.g. alias1=joe.smith&[email protected]. Ignores alias position values not specified. Aliases must be unique amongst users.
Username aliases for the user. Up to eight aliases may be specified with this parameter. Aliases must be unique amongst users.
.PARAMETER FullName
The real name (or full name) of this user.
Expand Down Expand Up @@ -72,13 +72,13 @@ function New-DuoUser {
)

if ($Aliases) {
$AliasCollection = [System.Web.HttpUtility]::ParseQueryString([String]::Empty)
foreach ($Item in ($Aliases.GetEnumerator() | Sort-Object -CaseSensitive -Property Key)) {
$AliasCollection.Add($Item.Key, $Item.Value)
$x = 1
$AliasList = $Aliases | ForEach-Object {
'alias{0}={1}' -f $x, [System.Uri]::EscapeDataString($_)
$x++
}
$AliasString = [System.Web.HttpUtility]::UrlDecode($AliasCollection.ToString())
$Params.aliases = $AliasList -join '&'
}

$Params = @{
username = $Username
}
Expand Down
9 changes: 4 additions & 5 deletions DuoSecurity/Public/Admin API/Users/Update-DuoUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function Update-DuoUser {
The new username.
.PARAMETER Aliases
Username aliases for the user. Up to eight aliases may be specified with this parameter as a set of URL-encoded key-value pairs e.g. alias1=joe.smith&[email protected]. Ignores alias position values not specified. Remove the value for an existing alias by specifying a blank value e.g. alias1=. Aliases must be unique amongst users.
Username aliases for the user. Up to eight aliases may be specified with this parameter. Aliases must be unique amongst users.
.PARAMETER FullName
The new real name (or full name).
Expand Down Expand Up @@ -76,12 +76,11 @@ function Update-DuoUser {
$Params = @{}
if ($Aliases) {
$x = 1
$AliasList = foreach ($Alias in $Aliases) {
if ($x -gt 8) { break }
@{ "alias$x" = $Alias }
$AliasList = $Aliases | ForEach-Object {
'alias{0}={1}' -f $x, [System.Uri]::EscapeDataString($_)
$x++
}
$Params.aliases = $AliasList
$Params.aliases = $AliasList -join '&'
}

if ($Username) { $Params.username = $Username }
Expand Down

0 comments on commit 34c92bd

Please sign in to comment.