This article describes the steps required to remove LDAPCPSE from your SharePoint farm.
Important
Do not merely retract the solution! The features must be manually deactivated and uninstalled before the solution is retracted.
Important
Do all the operations below on the server running the central administration, and in a new PowerShell process.
Reset property ClaimProviderName in the SPTrustedIdentityTokenIssuer#
Unfortunately, the only supported way to clear the property ClaimProviderName is to remove and recreate the SPTrustedIdentityTokenIssuer object. Alternatively, this property can be reset using .NET reflection, but this is not supported and you do this at your own risks:
# Set private member m_ClaimProviderName to null. Note that using .NET reflection on SharePoint objects is not supported and you do this at your own risks$trust=Get-SPTrustedIdentityTokenIssuer"<SPTRUST_NAME>"$trust.GetType().GetField("m_ClaimProviderName","NonPublic, Instance").SetValue($trust,$null)$trust.Update()
Run the following script on the server running the central administration, to completely uninstall LDAPCP SE from the SharePoint farm:
<#
.SYNOPSIS Uninstalls "LDAPCPSE.wsp" in a simple, automated way
.DESCRIPTION Run this script ONLY on the server running the central administration, in a new PowerShell process.
The script does not require any modification.
.LINK https://ldapcp.com/docs-se/usage/remove/
#>$product="LDAPCPSE"$featureNamePrefix="Yvand"Write-Host"Disables the features present in $product.wsp solution"Disable-SPFeature-Identity"$featureNamePrefix.$product"-Confirm:$false# This will remove the claims provider from the farmDisable-SPFeature-Identity"$featureNamePrefix.$product.Administration"-Url$([Microsoft.SharePoint.Administration.SPAdministrationWebApplication]::Local.Url)-Confirm:$falseWrite-Host"Uninstalls the features present in $product.wsp solution"Uninstall-SPFeature-Identity"$featureNamePrefix.$product"-Confirm:$falseUninstall-SPFeature-Identity"$featureNamePrefix.$product.Administration"-Confirm:$false# Sanity check: The solution should not be retracted until its features are properly removed, because it cannot be done afterwardif($null-eq(Get-SPFeature|?{$_.DisplayName-like"$featureNamePrefix.$product*"})-and$null-eq(Get-SPClaimProvider-Identity"$product"-ErrorActionSilentlyContinue)){Write-Host"Retracts the $product.wsp solution"Uninstall-SPSolution-Identity"$product.wsp"-Confirm:$false$count=0$maxAttempts=10do{Write-Host"Waiting for the solution $product.wsp to be retracted..."Start-Sleep-Seconds10$solution=Get-SPSolution-Identity"$product.wsp"$count++}while($count-lt$maxAttempts-and$false-ne$solution.Deployed-and$false-ne$solution.JobExists)if($false-eq$solution.Deployed-and$false-eq$solution.JobExists){Write-Host"Removes the $product.wsp solution"Remove-SPSolution-Identity"$product.wsp"-Confirm:$false}}
This script does the minimum work required in PowerShell, before you can safely retract the solution from the central administration.
Run the following script on the server running the central administration:
# Disables the features present in LDAPCPSE.wsp solutionDisable-SPFeature-Identity"Yvand.LDAPCPSE"# This will remove the claims provider from the farmDisable-SPFeature-Identity"Yvand.LDAPCPSE.Administration"-Url$([Microsoft.SharePoint.Administration.SPAdministrationWebApplication]::Local.Url)# Uninstalls the features present in LDAPCPSE.wsp solutionUninstall-SPFeature-Identity"Yvand.LDAPCPSE"Uninstall-SPFeature-Identity"Yvand.LDAPCPSE.Administration"# Sanity checkif($null-eq(Get-SPFeature|?{$_.DisplayName-like"Yvand.LDAPCPSE*"})-and$null-eq(Get-SPClaimProvider-Identity"LDAPCPSE"-ErrorActionSilentlyContinue)){Write-Host"You can now safely retract LDAPCPSE.wsp"}else{Write-Warning"You should not retract LDAPCPSE.wsp until all its features and its claims provider are properly removed. You won't be able to do it after you retracted the solution, unless you redeploy the solution"}
Browse to the central administration > System Settings > Manage farm solutions > LDAPCPSE.wsp > Retract Solution
Once the solution is retracted, click again on LDAPCPSE.wsp > Remove Solution