Introduction
A custom claims provider issues claims and packages claims into the security tokens, which can be used to give permission to the items in a customized way. Claims augmentation enables an application to augment the additional claims into the user token. Claims can be displayed in the people picker control through claims picking. In this article, I will explain how to activate Custom Claims Provider in SharePoint 2013, using Windows PowerShell.
Pre-Requisites
- Open Visual Studio.
- Open New Project dialog box. Expand Office/SharePoint node and then choose SharePoint solutions.
- Choose SharePoint 2013 – Empty project template. Name the project as ClaimProviderProject.
- Choose the Deploy as a farm solution option button and choose Finish button.
- To create a custom claims provider class file, right click ClaimProviderProject project -> Add -> New Item.
- Add the class file and name it as CustomClaimsProvider.cs.
- Complete the implementation of custom claims provider class by overriding the SPClaimProvider properties and methods.
Activate Custom Claims Provider
- Build this solution and take the WSP file.
- Using Windows PowerShell, add WSP file to SharePoint.
Add-SPSolution "D:\New folder\ClaimProviderProject\ClaimProviderProject\bin\Debug\ClaimProviderProject.wsp"
- Install WSP file to our Web Application.
- Install-SPSolution -WebApplication "http:\\www.siteURL.com" -GACDeployment
-
- -FullTrustBinDeployment -Identity Ascentn.SharePoint.SettingsList.wsp
-
- -CompatibilityLevel All
- Deploy the installed WSP file and enable the Claims provider feature at Farm solution level.
- Enable-SPFeature -Url "http:\\www.siteURL.com" -Identity CustomClaimsProvider
- Check whether the custom claims provider is enabled or not, using the script, given below-
- Get-SPClaimProvider -Identity "CustomClaimsProvider"
- Set the IsEnabled to True for the claim provider, if it is not enabled, using the script, given below-
- $kdealerClaimProviderDisplayName = "Custom Claims Provider"
- $manager = Get - SPClaimProviderManager
- $providers = $manager.ClaimProviders
- $provider = $providers | ? {
- $_.DisplayName - eq $kdealerClaimProviderDisplayName
- } | Select - First 1
- $provider.IsEnabled = $True
- $manager.Update()
- Add the provider association to the Web Application, using the script, given below-
- $webUrl = "http://www.siteURL.com"
- $zone = "Default"
- $claimProviderInternalName = "CustomClaimsProvider"
- $webApplication = Get - SPWebApplication $webUrl
- if ($webApplication.IisSettings.ContainsKey($zone))
- {
- $settings = $webApplication.GetIisSettingsWithFallback($zone)
- $providers = $settings.ClaimsProviders
- if (-not($providers.Contains($claimProviderInternalName))) {
- $providers += $claimProviderInternalName
- Set - SPWebApplication - Identity $WebApplication - Zone $Zone - AdditionalClaimProvider $providers
- Write - Host "Registered $claimProviderInternalName on $($webApplication.Url) in zone $zone"
- } else {
- Write - Host "$claimProviderInternalName already registered on $($webApplication.Url) in zone $zone"
- }
- }
- Check whether the custom claims provider is populated in the assigning permission to an item or not.
Summary
Thus, you have learned, how to activate custom claims provider in SharePoint 2013, using Windows PowerShell.