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, ValueFromPipeline=$false,
ValueFromPipelineByPropertyName=$false, ValueFromPipelineByPropertyName=$false,
HelpMessage='Password you want to use for authenticating with the server')] HelpMessage='Password you want to use for authenticating with the server')]
[string] [VMware.vSphere.SsoAdmin.Utils.StirngToSecureStringArgumentTransformationAttribute()]
[SecureString]
$Password, $Password,
[Parameter( [Parameter(
@@ -132,14 +133,16 @@ function Connect-SsoAdminServer {
-ArgumentList @( -ArgumentList @(
$Server, $Server,
$User, $User,
(ConvertTo-SecureString -String $Password -AsPlainText -Force), $Password,
$certificateValidator) $certificateValidator)
# Update $global:DefaultSsoAdminServers varaible if ($ssoAdminServer -ne $null) {
$global:DefaultSsoAdminServers.Add($ssoAdminServer) | Out-Null # Update $global:DefaultSsoAdminServers varaible
$global:DefaultSsoAdminServers.Add($ssoAdminServer) | Out-Null
# Function Output # Function Output
Write-Output $ssoAdminServer Write-Output $ssoAdminServer
}
} }
} }
@@ -327,7 +330,7 @@ function Get-PersonUser {
Github: https://github.com/dmilov Github: https://github.com/dmilov
=========================================================================== ===========================================================================
.DESCRIPTION .DESCRIPTION
This function gets new person user account. This function gets person user account.
.PARAMETER Name .PARAMETER Name
Specifies Name to filter on when searching for person user accounts. 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' $myNewPersonUser = New-PersonUser -Server $ssoAdminConnection -User myAdmin -Password 'MyStrongPa$$w0rd'
Remove-PersonUser -User $myNewPersonUser Remove-PersonUser -User $myNewPersonUser
Remove person user account with user name 'myAdmin' and password 'MyStrongPa$$w0rd' Remove person user account with user name 'myAdmin'
.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'
#> #>
[CmdletBinding(ConfirmImpact='High')] [CmdletBinding(ConfirmImpact='High')]
param( 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.Http" Version="4.4.0" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="4.4.0" /> <PackageReference Include="System.ServiceModel.NetTcp" Version="4.4.0" />
<PackageReference Include="System.ServiceModel.Security" 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>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'"> <ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
<PackageReference Include="Microsoft.WSMan.Runtime" Version="6.1.0" />
<PackageReference Include="VMware.System.Private.ServiceModel" Version="4.4.4" /> <PackageReference Include="VMware.System.Private.ServiceModel" Version="4.4.4" />
</ItemGroup> </ItemGroup>

View File

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