Implement ResetPassword and Unlock for PersonUser accounts.
This commit is contained in:
@@ -115,6 +115,30 @@ namespace VMware.vSphere.SsoAdminClient.Tests
|
||||
Assert.IsTrue(addActual);
|
||||
Assert.IsTrue(removeActual);
|
||||
|
||||
// Cleanup
|
||||
ssoAdminClient.DeleteLocalUser(
|
||||
newUser);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ResetUserPassword() {
|
||||
// Arrange
|
||||
var ssoAdminClient = new SsoAdminClient(_vc, _user, _password, new AcceptAllX509CertificateValidator());
|
||||
|
||||
var expectedUserName = "test-user6";
|
||||
var expectedPassword = "te$tPa$sW0rd";
|
||||
var updatePassword = "TE$tPa$sW0rd";
|
||||
var newUser = ssoAdminClient.CreateLocalUser(
|
||||
expectedUserName,
|
||||
expectedPassword);
|
||||
|
||||
// Act
|
||||
// Assert
|
||||
Assert.DoesNotThrow(() => {
|
||||
ssoAdminClient.ResetPersonUserPassword(newUser, updatePassword);
|
||||
});
|
||||
|
||||
|
||||
// Cleanup
|
||||
ssoAdminClient.DeleteLocalUser(
|
||||
newUser);
|
||||
|
||||
@@ -302,6 +302,42 @@ namespace VMware.vSphere.SsoAdminClient
|
||||
},
|
||||
group.Name)).Result;
|
||||
}
|
||||
|
||||
public void ResetPersonUserPassword(PersonUser user, string newPassword) {
|
||||
// Create Authorization Invocation Context
|
||||
var authorizedInvocationContext =
|
||||
CreateAuthorizedInvocationContext();
|
||||
|
||||
// Invoke SSO Admin ResetLocalPersonUserPasswordAsync operation
|
||||
authorizedInvocationContext.
|
||||
InvokeOperation(() =>
|
||||
_ssoAdminBindingClient.ResetLocalPersonUserPasswordAsync(
|
||||
new ManagedObjectReference {
|
||||
type = "SsoAdminPrincipalManagementService",
|
||||
Value = "principalManagementService"
|
||||
},
|
||||
user.Name,
|
||||
newPassword)).Wait();
|
||||
}
|
||||
|
||||
public bool UnlockPersonUser(PersonUser user) {
|
||||
// Create Authorization Invocation Context
|
||||
var authorizedInvocationContext =
|
||||
CreateAuthorizedInvocationContext();
|
||||
|
||||
// Invoke SSO Admin UnlockUserAccountAsync operation
|
||||
return authorizedInvocationContext.
|
||||
InvokeOperation(() =>
|
||||
_ssoAdminBindingClient.UnlockUserAccountAsync(
|
||||
new ManagedObjectReference {
|
||||
type = "SsoAdminPrincipalManagementService",
|
||||
Value = "principalManagementService"
|
||||
},
|
||||
new SsoPrincipalId {
|
||||
name = user.Name,
|
||||
domain = user.Domain
|
||||
})).Result;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user