vmware / PowerCLI-Example-Scripts

http://blogs.vmware.com/powercli
Other
746 stars 603 forks source link

[VMware.vSphere.SsoAdmin] New-SsoPersonUser throws error 'One or more errors occurred' #519

Closed GaryJBlake closed 2 years ago

GaryJBlake commented 2 years ago

Describe the bug

When attempting to add a user to the SSO Domain using New-SsoPersonUser it throws an error 'One or more errors occurred'.

New-SsoPersonUser -UserName TestAccount -Password VMw@re1! -Server $ssoConnectionDetails

New-SsoPersonUser : One or more errors occurred. At line:1 char:1

Reproduction steps

1. Connect to SSO Domain: $ssoConnectionDetails = Connect-SsoAdminServer -Server sfo-m01-vc01.sfo.rainpole.io -User administrator@vsphere.local -Password VMw@re1!
2. Issue new account creation: New-SsoPersonUser -UserName TestAccount -Password VMw@re1! -Server $ssoConnectionDetails

I've also tried without the -Server switch and a single SSO Server connected with the same outcome

Expected behavior

Account should be created without an error

Additional context

No response

dmilov commented 2 years ago

Error handling in the module is not good enough here. The real server error after debugging with http proxy is

Failed: cannot create person user for user TestAccount because password policy is not satisfied
Caused by: Constraint violation

The fix should be to expose the server error details to the user.

dmilov commented 2 years ago

Version 1.3.8 on Windoiws PowerShell 7.0 works correct with the error handling:

> New-SsoPersonUser -UserName 'testuser' -Password 'd'
New-SsoPersonUser: One or more errors occurred. (The specified principal (testuser) is invalid.
Caused by: Another user or group already exists with the same name: accountName=testuser, principal=testuser@vsphere.local)
PS C:\Users\dmilov> New-SsoPersonUser -UserName 'testuser2' -Password 'd'
New-SsoPersonUser: One or more errors occurred. (Failed: cannot create person user for user testuser2 because password policy is not satisfied
Caused by: Constraint violation)
dmilov commented 2 years ago

1.3.8 is available on PS Gallery