Address PR discussions

This commit is contained in:
dmilov
2020-10-05 10:39:52 +03:00
parent 4ca1a612ab
commit 68e777357c
8 changed files with 52 additions and 14 deletions

View File

@@ -112,7 +112,8 @@ function Connect-SsoAdminServer {
ValueFromPipeline=$false,
ValueFromPipelineByPropertyName=$false,
HelpMessage='Password you want to use for authenticating with the server')]
[string]
[VMware.vSphere.SsoAdmin.Utils.StirngToSecureStringArgumentTransformationAttribute()]
[SecureString]
$Password,
[Parameter(
@@ -132,14 +133,16 @@ function Connect-SsoAdminServer {
-ArgumentList @(
$Server,
$User,
(ConvertTo-SecureString -String $Password -AsPlainText -Force),
$Password,
$certificateValidator)
# Update $global:DefaultSsoAdminServers varaible
$global:DefaultSsoAdminServers.Add($ssoAdminServer) | Out-Null
if ($ssoAdminServer -ne $null) {
# Update $global:DefaultSsoAdminServers varaible
$global:DefaultSsoAdminServers.Add($ssoAdminServer) | Out-Null
# Function Output
Write-Output $ssoAdminServer
# Function Output
Write-Output $ssoAdminServer
}
}
}
@@ -327,7 +330,7 @@ function Get-PersonUser {
Github: https://github.com/dmilov
===========================================================================
.DESCRIPTION
This function gets new person user account.
This function gets person user account.
.PARAMETER Name
Specifies Name to filter on when searching for person user accounts.
@@ -570,12 +573,7 @@ function Remove-PersonUser {
$myNewPersonUser = New-PersonUser -Server $ssoAdminConnection -User myAdmin -Password 'MyStrongPa$$w0rd'
Remove-PersonUser -User $myNewPersonUser
Remove person user account with user name 'myAdmin' and password 'MyStrongPa$$w0rd'
.EXAMPLE
New-PersonUser -User myAdmin -Password 'MyStrongPa$$w0rd' -EmailAddress 'myAdmin@mydomain.com' -FirstName 'My' -LastName 'Admin'
Creates person user account with user name 'myAdmin', password 'MyStrongPa$$w0rd', and details against connections available in 'DefaultSsoAdminServers'
Remove person user account with user name 'myAdmin'
#>
[CmdletBinding(ConfirmImpact='High')]
param(

View File

@@ -0,0 +1,38 @@
// **************************************************************************
// Copyright 2020 VMware, Inc.
// **************************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Security;
using System.Text;
using System.Threading.Tasks;
namespace VMware.vSphere.SsoAdmin.Utils
{
public class StirngToSecureStringArgumentTransformationAttribute : ArgumentTransformationAttribute
{
private static class SecureStringConverter
{
public static SecureString ToSecureString(string value) {
var result = new SecureString();
foreach (var c in value.ToCharArray()) {
result.AppendChar(c);
}
return result;
}
}
public override object Transform(EngineIntrinsics engineIntrinsics, object inputData) {
object result = inputData;
if (inputData is string s) {
result = SecureStringConverter.ToSecureString(s);
}
return result;
}
}
}

View File

@@ -14,9 +14,11 @@
<PackageReference Include="System.ServiceModel.Http" Version="4.4.0" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="4.4.0" />
<PackageReference Include="System.ServiceModel.Security" Version="4.4.0" />
<PackageReference Include="Microsoft.PowerShell.5.ReferenceAssemblies" Version="1.0.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
<PackageReference Include="Microsoft.WSMan.Runtime" Version="6.1.0" />
<PackageReference Include="VMware.System.Private.ServiceModel" Version="4.4.4" />
</ItemGroup>

View File

@@ -13,7 +13,7 @@ namespace VMware.vSphere.SsoAdminClient.Tests
{
private string _vc = "<vc>";
private string _user = "<user>";
private string _rawPassword = "<password";
private string _rawPassword = "<password>";
private SecureString _password;
[SetUp]
public void Setup() {