Fix issue #460 adding PasswordExpirationRemainingDays property to the PersonUser object (#463)

Signed-off-by: Dimitar Milov <dmilov@vmware.com>
This commit is contained in:
dmilov
2021-06-07 10:42:18 +03:00
committed by GitHub
parent fb641c8a1c
commit 1dd718eb3a
8 changed files with 59 additions and 7 deletions

View File

@@ -16,7 +16,7 @@ SPDX-License-Identifier: BSD-2-Clause
RootModule = 'VMware.vSphere.SsoAdmin.psm1'
# Version number of this module.
ModuleVersion = '1.3.0'
ModuleVersion = '1.3.1'
# ID used to uniquely identify this module
GUID = 'b3e25326-e809-4d68-a252-ca5fcaf1eb8b'

View File

@@ -26,6 +26,8 @@ namespace VMware.vSphere.SsoAdminClient.DataTypes
public bool Locked { get; set; }
public bool Disabled { get; set; }
public Nullable<int> PasswordExpirationRemainingDays { get; set; }
public SsoAdminClient GetClient() {
return _client;
}

View File

@@ -207,6 +207,25 @@ namespace VMware.vSphere.SsoAdminClient
name = userName,
domain = domain
})).Result;
Nullable<int> passwordRemainingDays = null;
try {
passwordRemainingDays = wsSecurityContext.
InvokeOperation(() =>
_ssoAdminBindingClient.GetDaysRemainingUntilPasswordExpirationAsync(
new ManagedObjectReference
{
type = "SsoAdminPrincipalManagementService",
Value = "principalManagementService"
},
new SsoPrincipalId
{
name = userName,
domain = domain
})).Result;
} catch {}
return new PersonUser(this)
{
Name = personUser.id.name,
@@ -216,7 +235,8 @@ namespace VMware.vSphere.SsoAdminClient
LastName = personUser.details.lastName,
EmailAddress = personUser.details.emailAddress,
Locked = personUser.locked,
Disabled = personUser.disabled
Disabled = personUser.disabled,
PasswordExpirationRemainingDays = passwordRemainingDays
};
}
@@ -246,6 +266,18 @@ namespace VMware.vSphere.SsoAdminClient
{
foreach (var personUser in personUsers)
{
Nullable<int> passwordRemainingDays = null;
try {
passwordRemainingDays = authorizedInvocationContext.
InvokeOperation(() =>
_ssoAdminBindingClient.GetDaysRemainingUntilPasswordExpirationAsync(
new ManagedObjectReference
{
type = "SsoAdminPrincipalManagementService",
Value = "principalManagementService"
},
personUser.id)).Result;
} catch {}
yield return new PersonUser(this)
{
Name = personUser.id.name,
@@ -255,7 +287,8 @@ namespace VMware.vSphere.SsoAdminClient
LastName = personUser.details.lastName,
EmailAddress = personUser.details.emailAddress,
Locked = personUser.locked,
Disabled = personUser.disabled
Disabled = personUser.disabled,
PasswordExpirationRemainingDays = passwordRemainingDays
};
}
}
@@ -289,8 +322,21 @@ namespace VMware.vSphere.SsoAdminClient
{
foreach (var personUser in personUsers)
{
yield return new PersonUser(this)
{
Nullable<int> passwordRemainingDays = null;
try
{
passwordRemainingDays = authorizedInvocationContext.
InvokeOperation(() =>
_ssoAdminBindingClient.GetDaysRemainingUntilPasswordExpirationAsync(
new ManagedObjectReference
{
type = "SsoAdminPrincipalManagementService",
Value = "principalManagementService"
},
personUser.id)).Result;
} catch {}
yield return new PersonUser(this)
{
Name = personUser.id.name,
Domain = personUser.id.domain,
Description = personUser.details.description,
@@ -298,8 +344,9 @@ namespace VMware.vSphere.SsoAdminClient
LastName = personUser.details.lastName,
EmailAddress = personUser.details.emailAddress,
Locked = personUser.locked,
Disabled = personUser.disabled
};
Disabled = personUser.disabled,
PasswordExpirationRemainingDays = passwordRemainingDays
};
}
}
}

View File

@@ -101,6 +101,7 @@ Describe "PersonUser Tests" {
$actual.FirstName | Should -Be $null
$actual.LastName | Should -Be $null
$actual.EmailAddress | Should -Be $null
$actual.PasswordExpirationRemainingDays | Should -Not -Be $null
}
}
@@ -121,6 +122,7 @@ Describe "PersonUser Tests" {
$actual.Count | Should -BeGreaterThan 0
$actual[0].Name | Should -Not -Be $null
$actual[0].Domain | Should -Be 'localos'
$actual[0].PasswordExpirationRemainingDays | Should -Not -Be $null
}
It 'Gets person users by name (exact match) and domain filters' {
@@ -278,6 +280,7 @@ Describe "PersonUser Tests" {
$actual.Count | Should -BeGreaterThan 0
$actual[0].Name | Should -Not -Be $null
$actual[0].Domain | Should -Be 'vsphere.local'
$actual[0].PasswordExpirationRemainingDays | Should -Not -Be $null
}
}