Implement Set Default Identity Source and Get Default Identity Source (#545)
Signed-off-by: Dimitar Milov <dmilov@vmware.com>
This commit is contained in:
@@ -42,6 +42,9 @@ function Add-ExternalDomainIdentitySource {
|
||||
.PARAMETER DomainServerType
|
||||
Type of the ExternalDomain, one of 'ActiveDirectory','OpenLdap','NIS'
|
||||
|
||||
.PARAMETER Default
|
||||
Sets the Identity Source as the defualt for the SSO
|
||||
|
||||
.PARAMETER Server
|
||||
Specifies the vSphere Sso Admin Server on which you want to run the cmdlet.
|
||||
If not specified the servers available in $global:DefaultSsoAdminServers variable will be used.
|
||||
@@ -139,6 +142,14 @@ function Add-ExternalDomainIdentitySource {
|
||||
[string]
|
||||
$DomainServerType = 'ActiveDirectory',
|
||||
|
||||
[Parameter(
|
||||
Mandatory = $false,
|
||||
ValueFromPipeline = $false,
|
||||
ValueFromPipelineByPropertyName = $false,
|
||||
HelpMessage = 'Sets the Identity Source as default')]
|
||||
[Switch]
|
||||
$Default,
|
||||
|
||||
[Parameter(
|
||||
Mandatory = $false,
|
||||
ValueFromPipeline = $false,
|
||||
@@ -170,6 +181,10 @@ function Add-ExternalDomainIdentitySource {
|
||||
$Username,
|
||||
$Password,
|
||||
$DomainServerType);
|
||||
|
||||
if ($Default) {
|
||||
$connection.Client.SetDefaultIdentitySource($Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
@@ -225,6 +240,9 @@ function Add-LDAPIdentitySource {
|
||||
.PARAMETER Certificates
|
||||
List of X509Certicate2 LDAP certificates
|
||||
|
||||
.PARAMETER Default
|
||||
Sets the Identity Source as the defualt for the SSO
|
||||
|
||||
.PARAMETER Server
|
||||
Specifies the vSphere Sso Admin Server on which you want to run the cmdlet.
|
||||
If not specified the servers available in $global:DefaultSsoAdminServers variable will be used.
|
||||
@@ -349,6 +367,14 @@ function Add-LDAPIdentitySource {
|
||||
[string]
|
||||
$ServerType = 'ActiveDirectory',
|
||||
|
||||
[Parameter(
|
||||
Mandatory = $false,
|
||||
ValueFromPipeline = $false,
|
||||
ValueFromPipelineByPropertyName = $false,
|
||||
HelpMessage = 'Sets the Identity Source as default')]
|
||||
[Switch]
|
||||
$Default,
|
||||
|
||||
[Parameter(
|
||||
Mandatory = $false,
|
||||
ValueFromPipeline = $false,
|
||||
@@ -392,6 +418,10 @@ function Add-LDAPIdentitySource {
|
||||
$authenticationPassword,
|
||||
$ServerType,
|
||||
$Certificates);
|
||||
|
||||
if ($Default) {
|
||||
$connection.Client.SetDefaultIdentitySource($Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
@@ -426,6 +456,9 @@ function Set-LDAPIdentitySource {
|
||||
.PARAMETER Credential
|
||||
Domain authentication credential
|
||||
|
||||
.PARAMETER Default
|
||||
Sets the Identity Source as the defualt for the SSO
|
||||
|
||||
.PARAMETER Server
|
||||
Specifies the vSphere Sso Admin Server on which you want to run the cmdlet.
|
||||
If not specified the servers available in $global:DefaultSsoAdminServers variable will be used.
|
||||
@@ -499,6 +532,15 @@ function Set-LDAPIdentitySource {
|
||||
[PSCredential]
|
||||
$Credential,
|
||||
|
||||
[Parameter(
|
||||
Mandatory = $false,
|
||||
ValueFromPipeline = $false,
|
||||
ValueFromPipelineByPropertyName = $false,
|
||||
ParameterSetName = 'SetAsDefault',
|
||||
HelpMessage = 'Sets the Identity Source as default')]
|
||||
[Switch]
|
||||
$Default,
|
||||
|
||||
[Parameter(
|
||||
Mandatory = $false,
|
||||
ValueFromPipeline = $false,
|
||||
@@ -549,6 +591,92 @@ function Set-LDAPIdentitySource {
|
||||
$authenticationUserName,
|
||||
$authenticationPassword);
|
||||
}
|
||||
|
||||
if ($Default) {
|
||||
$connection.Client.SetDefaultIdentitySource($IdentitySource.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Error (FormatError $_.Exception)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Set-IdentitySource {
|
||||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created on: 2/25/2022
|
||||
Created by: Dimitar Milov
|
||||
Twitter: @dimitar_milov
|
||||
Github: https://github.com/dmilov
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
Updates IDentitySource
|
||||
|
||||
.PARAMETER IdentitySource
|
||||
Identity Source to update
|
||||
|
||||
.PARAMETER Default
|
||||
Sets the Identity Source as the defualt for the SSO
|
||||
|
||||
.PARAMETER Server
|
||||
Specifies the vSphere Sso Admin Server on which you want to run the cmdlet.
|
||||
If not specified the servers available in $global:DefaultSsoAdminServers variable will be used.
|
||||
|
||||
Updates LDAP Identity Source
|
||||
|
||||
.EXAMPLE
|
||||
|
||||
Updates certificate of a LDAP identity source
|
||||
|
||||
Get-IdentitySource -External | Set-IdentitySource -Default
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(
|
||||
Mandatory = $true,
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $false,
|
||||
HelpMessage = 'Identity source to update')]
|
||||
[ValidateNotNull()]
|
||||
[VMware.vSphere.SsoAdminClient.DataTypes.IdentitySource]
|
||||
$IdentitySource,
|
||||
|
||||
[Parameter(
|
||||
Mandatory = $false,
|
||||
ValueFromPipeline = $false,
|
||||
ValueFromPipelineByPropertyName = $false,
|
||||
HelpMessage = 'Sets the Identity Source as default')]
|
||||
[Switch]
|
||||
$Default,
|
||||
|
||||
[Parameter(
|
||||
Mandatory = $false,
|
||||
ValueFromPipeline = $false,
|
||||
ValueFromPipelineByPropertyName = $false,
|
||||
HelpMessage = 'Connected SsoAdminServer object')]
|
||||
[ValidateNotNull()]
|
||||
[VMware.vSphere.SsoAdminClient.DataTypes.SsoAdminServer]
|
||||
$Server)
|
||||
|
||||
Process {
|
||||
$serversToProcess = $global:DefaultSsoAdminServers.ToArray()
|
||||
if ($null -ne $Server) {
|
||||
$serversToProcess = $Server
|
||||
}
|
||||
|
||||
try {
|
||||
foreach ($connection in $serversToProcess) {
|
||||
if (-not $connection.IsConnected) {
|
||||
Write-Error "Server $connection is disconnected"
|
||||
continue
|
||||
}
|
||||
|
||||
if ($Default) {
|
||||
$connection.Client.SetDefaultIdentitySource($IdentitySource.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
@@ -578,6 +706,9 @@ function Get-IdentitySource {
|
||||
.PARAMETER External
|
||||
Filter parameter to return only the external domain identity sources
|
||||
|
||||
.PARAMETER Default
|
||||
Filter parameter to return only the default domain identity sources
|
||||
|
||||
.PARAMETER Server
|
||||
Specifies the vSphere Sso Admin Server on which you want to run the cmdlet.
|
||||
If not specified the servers available in $global:DefaultSsoAdminServers variable will be used.
|
||||
@@ -614,6 +745,14 @@ function Get-IdentitySource {
|
||||
[Switch]
|
||||
$External,
|
||||
|
||||
[Parameter(
|
||||
Mandatory = $false,
|
||||
ValueFromPipeline = $false,
|
||||
ValueFromPipelineByPropertyName = $false,
|
||||
HelpMessage = 'Returns only the default domain identity sources')]
|
||||
[Switch]
|
||||
$Default,
|
||||
|
||||
[Parameter(
|
||||
Mandatory = $false,
|
||||
ValueFromPipeline = $false,
|
||||
@@ -652,6 +791,12 @@ function Get-IdentitySource {
|
||||
$resultIdentitySources += $allIdentitySources | Where-Object { $_ -is [VMware.vSphere.SsoAdminClient.DataTypes.ActiveDirectoryIdentitySource] }
|
||||
}
|
||||
|
||||
if ($Default) {
|
||||
$resultIdentitySources = @()
|
||||
$defaultDomainName = $connection.Client.GetDefaultIdentitySourceDomainName()
|
||||
$resultIdentitySources = $allIdentitySources | Where-Object { $_.Name -eq $defaultDomainName }
|
||||
}
|
||||
|
||||
#Return result
|
||||
$resultIdentitySources
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user