Thursday, February 2, 2012

Sharepoint 2010 : How to map Claim Provider with Token issuer

The main purpose of a custom claims provide is 
1) Name resolution & 
2) Claims augmentation. 

The token issuer (for example ADFS) issues claims and the custom claims provider will provide name resolution and augment for those claims issued by the token issuer. Thus, you need to map both claims provider and token issuer. If we do not map them, then the claims we resolve in the search dialog or type-in control will not map to the account name or other claim that someone logs in with.

Object Model Code

            SPSecurityTokenServiceManager manager = SPSecurityTokenServiceManager.Local;
            SPTrustedLoginProviderCollection providers=manager.TrustedLoginProviders;
          
            foreach (SPTrustedLoginProvider i in providers) //I have looped all the trusted provider
            {
//you can check the name before applying the custom claim provider
                i.ClaimProviderName = "CustomClaimsProviderName";
                i.Update();
            }
            manager.Update();



Powershell Script

$trustedProv = Get-SPTrustedIdentityTokenIssuer -Identity "Trusted Login Provider Name"
$trustedProv.ClaimProviderName = “Custom Claims Provider Name”  
$trustedProv.Update()

No comments:

Post a Comment