Implement Remove-IdentitySource

Add FailoverUrl Property to ActiveDirectory identity source
This commit is contained in:
Dimitar Milov
2021-03-19 09:41:19 +02:00
parent 5fda0c70d5
commit ed4f05238f
8 changed files with 93 additions and 1 deletions

View File

@@ -34,7 +34,7 @@ RequiredModules = @(
)
# Functions to export from this module
FunctionsToExport = @('Connect-SsoAdminServer', 'Disconnect-SsoAdminServer', 'New-SsoPersonUser', 'Get-SsoPersonUser', 'Set-SsoPersonUser', 'Remove-SsoPersonUser', 'Get-SsoGroup', 'Get-SsoPasswordPolicy', 'Set-SsoPasswordPolicy', 'Get-SsoLockoutPolicy', 'Set-SsoLockoutPolicy', 'Get-SsoTokenLifetime', 'Set-SsoTokenLifetime', 'Get-IdentitySource', 'Add-ActiveDirectoryIdentitySource', 'Add-LDAPIdentitySource', 'Set-LDAPIdentitySource', 'Set-SsoSelfPersonUserPassword')
FunctionsToExport = @('Connect-SsoAdminServer', 'Disconnect-SsoAdminServer', 'New-SsoPersonUser', 'Get-SsoPersonUser', 'Set-SsoPersonUser', 'Remove-SsoPersonUser', 'Get-SsoGroup', 'Get-SsoPasswordPolicy', 'Set-SsoPasswordPolicy', 'Get-SsoLockoutPolicy', 'Set-SsoLockoutPolicy', 'Get-SsoTokenLifetime', 'Set-SsoTokenLifetime', 'Get-IdentitySource', 'Remove-IdentitySource', 'Add-ActiveDirectoryIdentitySource', 'Add-LDAPIdentitySource', 'Set-LDAPIdentitySource', 'Set-SsoSelfPersonUserPassword')
# Cmdlets to export from this module
CmdletsToExport = @()

View File

@@ -1833,6 +1833,7 @@ Process {
$IdentitySource.Name,
$IdentitySource.FriendlyName,
$IdentitySource.PrimaryUrl,
$IdentitySource.FailoverUrl,
$IdentitySource.UserBaseDN,
$IdentitySource.GroupBaseDN,
$Certificates);
@@ -1942,4 +1943,72 @@ function Get-IdentitySource {
$resultIdentitySources
}
}
function Remove-IdentitySource {
<#
.NOTES
===========================================================================
Created on: 03/19/2021
Created by: Dimitar Milov
Twitter: @dimitar_milov
Github: https://github.com/dmilov
===========================================================================
.DESCRIPTION
This function removes Identity Source.
.PARAMETER IdentitySource
The identity source to remove
.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.
.EXAMPLE
Get-IdentitySource -External | Remove-IdentitySource
Removes all external domain identity source
#>
[CmdletBinding()]
param(
[Parameter(
Mandatory=$true,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$false,
HelpMessage='Identity source to remove')]
[ValidateNotNull()]
[VMware.vSphere.SsoAdminClient.DataTypes.IdentitySource]
$IdentitySource,
[Parameter(
Mandatory=$false,
ValueFromPipeline=$false,
ValueFromPipelineByPropertyName=$false,
HelpMessage='Connected SsoAdminServer object')]
[ValidateNotNull()]
[VMware.vSphere.SsoAdminClient.DataTypes.SsoAdminServer]
$Server)
Process {
$serversToProcess = $global:DefaultSsoAdminServers.ToArray()
if ($Server -ne $null) {
$serversToProcess = $Server
}
try {
foreach ($connection in $serversToProcess) {
if (-not $connection.IsConnected) {
Write-Error "Server $connection is disconnected"
continue
}
$connection.Client.DeleteDomain($IdentitySource.Name)
}
} catch {
Write-Error (FormatError $_.Exception)
}
}
}
#endregion

View File

@@ -20,6 +20,7 @@ namespace VMware.vSphere.SsoAdminClient.DataTypes
public string FriendlyName { get; set; }
public string PrimaryUrl { get; set; }
public string FailoverUrl { get; set; }
public string UserBaseDN { get; set; }
public string GroupBaseDN { get; set; }
}

View File

@@ -787,6 +787,7 @@ namespace VMware.vSphere.SsoAdminClient
string name,
string friendlyName,
string primaryUrl,
string failoverUrl,
string baseDNUsers,
string baseDNGroups,
X509Certificate2[] ldapCertificates) {
@@ -797,6 +798,7 @@ namespace VMware.vSphere.SsoAdminClient
var adminLdapIdentitySourceDetails = new SsoAdminLdapIdentitySourceDetails {
friendlyName = friendlyName,
primaryUrl = primaryUrl,
failoverUrl = failoverUrl,
userBaseDn = baseDNUsers,
groupBaseDn = baseDNGroups
};
@@ -858,6 +860,7 @@ namespace VMware.vSphere.SsoAdminClient
extIdentitySource.AuthenticationUsername = externalDomain.authenticationDetails?.username;
extIdentitySource.FriendlyName = externalDomain.details?.friendlyName;
extIdentitySource.PrimaryUrl = externalDomain.details?.primaryUrl;
extIdentitySource.FailoverUrl = externalDomain.details?.failoverUrl;
extIdentitySource.GroupBaseDN = externalDomain.details?.groupBaseDn;
extIdentitySource.UserBaseDN = externalDomain.details?.userBaseDn;
yield return extIdentitySource;
@@ -865,6 +868,25 @@ namespace VMware.vSphere.SsoAdminClient
}
}
}
public void DeleteDomain(string name) {
var authorizedInvocationContext =
CreateAuthorizedInvocationContext();
try {
authorizedInvocationContext.
InvokeOperation(() =>
_ssoAdminBindingClient.DeleteAsync(
new ManagedObjectReference {
type = "SsoAdminIdentitySourceManagementService",
Value = "identitySourceManagementService"
},
name)).Wait();
} catch (AggregateException e) {
throw e.InnerException;
}
}
#endregion
}
}