SPClaimProviderManager.AddClaimProvider method
Adds a claims provider to be used by the local farm.
Namespace: Microsoft.SharePoint.Administration.Claims
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaration
Public Sub AddClaimProvider ( _
claimProviderDefinition As SPClaimProviderDefinition _
)
'Usage
Dim instance As SPClaimProviderManager
Dim claimProviderDefinition As SPClaimProviderDefinition
instance.AddClaimProvider(claimProviderDefinition)
public void AddClaimProvider(
SPClaimProviderDefinition claimProviderDefinition
)
Parameters
claimProviderDefinition
Type: Microsoft.SharePoint.Administration.Claims.SPClaimProviderDefinitionDefinition for the claims provider to add.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | Thrown when claimProviderDefinition is a null reference (Nothing in Visual Basic). |
ArgumentException | Thrown when claimProviderDefinition is invalid or defines a claims provider with a name that is already registered.. |
NotImplementedException | Thrown when SupportsHierachy() is false. |
Remarks
The following is an example of how to add a claims provider.
Sample code provided by: Steve Peschka, Microsoft Corporation.
SPClaimProviderManager cpm = SPClaimProviderManager.Local;
//This is my custom claims provider.
//Modify UslClaims to reflect your value.
UslClaims cp = new UslClaims(UslClaims.ProviderDisplayName); //This is a static property on my custom claims provider class.
// Creates a new definition for the claims provider to be added.
// Modify UslClaims to reflect your value.
SPClaimProviderDefinition cpd = new SPClaimProviderDefinition
(UslClaims.ProviderDisplayName,
"My description",
cp.GetType().Assembly.FullName, cp.GetType().FullName);
cpd.IsEnabled = true;
cpd.IsUsedByDefault = true;
// Adds the claims provider.
cpm.AddClaimProvider(cpd);
// Updates the claims provider manager.
cpm.Update();