Implement Enable/Disable Person Uer account in the Set-SsoPersonUser cmdlet (#471)

Signed-off-by: Dimitar Milov <dmilov@vmware.com>
This commit is contained in:
dmilov
2021-07-23 15:11:42 +03:00
committed by GitHub
parent 246a887e84
commit 0cbd85190c
11 changed files with 110 additions and 19991 deletions

View File

@@ -700,6 +700,50 @@ namespace VMware.vSphere.SsoAdminClient
})).Result;
}
public bool EnablePersonUser(PersonUser user)
{
// Create Authorization Invocation Context
var authorizedInvocationContext =
CreateAuthorizedInvocationContext();
// Invoke SSO Admin EnableUserAccountAsync operation
return authorizedInvocationContext.
InvokeOperation(() =>
_ssoAdminBindingClient.EnableUserAccountAsync(
new ManagedObjectReference
{
type = "SsoAdminPrincipalManagementService",
Value = "principalManagementService"
},
new SsoPrincipalId
{
name = user.Name,
domain = user.Domain
})).Result;
}
public bool DisablePersonUser(PersonUser user)
{
// Create Authorization Invocation Context
var authorizedInvocationContext =
CreateAuthorizedInvocationContext();
// Invoke SSO Admin DisableUserAccountAsync operation
return authorizedInvocationContext.
InvokeOperation(() =>
_ssoAdminBindingClient.DisableUserAccountAsync(
new ManagedObjectReference
{
type = "SsoAdminPrincipalManagementService",
Value = "principalManagementService"
},
new SsoPrincipalId
{
name = user.Name,
domain = user.Domain
})).Result;
}
public PasswordPolicy GetPasswordPolicy()
{
PasswordPolicy result = null;

View File

@@ -406,6 +406,41 @@ Describe "PersonUser Tests" {
# Assert
$actual | Should -Be $null
}
It 'Disables and enables person user' {
# Arrange
$userName = "TestEnablePersonUserName"
$userPassword = '$tr0NG_TestPa$$w0rd'
$connection = Connect-SsoAdminServer `
-Server $VcAddress `
-User $User `
-Password $Password `
-SkipCertificateCheck
$personUserToUpdate = New-SsoPersonUser `
-UserName $userName `
-Password $userPassword `
-Server $connection
$script:usersToCleanup += $personUserToUpdate
# Act
$personUserToUpdate.Disabled | Should -Be $false
$actual = Set-SsoPersonUser `
-User $personUserToUpdate `
-Enable $false
# Assert
$actual.Disabled | Should -Be $true
# Act
$actual = Set-SsoPersonUser `
-User $actual `
-Enable $true
# Assert
$actual.Disabled | Should -Be $false
}
}
Context "Remove-SsoPersonUser" {