From 36d1cff3224a0241248e7c9ddff963523966cfdf Mon Sep 17 00:00:00 2001 From: ISOBE Kazuhiko Date: Fri, 3 Apr 2020 13:48:17 +0900 Subject: [PATCH 1/2] add: Set Password API --- Okta.psm1 | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Okta.psm1 b/Okta.psm1 index 00beb5c..0181776 100644 --- a/Okta.psm1 +++ b/Okta.psm1 @@ -1918,6 +1918,43 @@ function oktaResetPasswordbyID() return $request } +function oktaSetPasswordbyID() +{ + param + ( + [parameter(Mandatory=$false)][ValidateLength(1,100)][String]$oOrg=$oktaDefOrg, + [parameter(Mandatory=$true)][ValidateLength(20,20)][String]$uid, + [parameter(Mandatory=$true)][Security.SecureString]$password + ) + $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($password) + $PlainPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) + $psobj = @{ + "credentials" = @{ + "password" = @{ "value" = $PlainPassword } + } + } + + [string]$method = "Put" + [string]$resource = "/api/v1/users/" + $uid + try + { + $request = _oktaNewCall -oOrg $oOrg -method $method -resource $resource -body $psobj + } + catch + { + if ($oktaVerbose -eq $true) + { + Write-Host -ForegroundColor red -BackgroundColor white $_.TargetObject + } + throw $_ + } + foreach ($user in $request) + { + $user = OktaUserfromJson -user $user + } + return $request +} + function oktaConvertUsertoFederation() { param From 539d3d3cd90bfeb60c4798f9904516d12f5947b7 Mon Sep 17 00:00:00 2001 From: ISOBE Kazuhiko Date: Fri, 3 Apr 2020 14:15:12 +0900 Subject: [PATCH 2/2] add: New API to README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 54f2859..136fbe6 100644 --- a/README.md +++ b/README.md @@ -224,6 +224,7 @@ catch - oktaResetFactorsbyUser - oktaResetPasswordbyID - oktaSetAppidCredentialUsername +- oktaSetPasswordbyID - oktaUnlockUserbyId - oktaUpdateApp - oktaUpdateAppExternalIdbyUserId