共用方式為


SPClaimProvider.FillSearch Method

When implemented in a derived class, fills search results in People Picker control window.

Namespace:  Microsoft.SharePoint.Administration.Claims
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
Protected MustOverride Sub FillSearch ( _
    context As Uri, _
    entityTypes As String(), _
    searchPattern As String, _
    hierarchyNodeID As String, _
    maxCount As Integer, _
    searchTree As SPProviderHierarchyTree _
)
'Usage
Dim context As Uri
Dim entityTypes As String()
Dim searchPattern As String
Dim hierarchyNodeID As String
Dim maxCount As Integer
Dim searchTree As SPProviderHierarchyTree

Me.FillSearch(context, entityTypes, _
    searchPattern, hierarchyNodeID, _
    maxCount, searchTree)
protected abstract void FillSearch(
    Uri context,
    string[] entityTypes,
    string searchPattern,
    string hierarchyNodeID,
    int maxCount,
    SPProviderHierarchyTree searchTree
)

Parameters

  • context
    Type: System.Uri

    The context, as a URI. This must be a properly formatted URI.

  • entityTypes
    Type: []

    The EntityType entity types set to scope the search to.

  • hierarchyNodeID
    Type: System.String

    The unique identifier of the hierarchy node.

  • maxCount
    Type: System.Int32

    A Int32 value that contains the maximum number of providers to be returned in the list.

Remarks

If you want to be able to search for claims in the People Picker control, you must implement this method and **SupportSearch()**property.

The SupportsSearch must return true.

For demonstration purpose, the search function only supports the full name search. As you can see, the claims provider supports two claims as principal: SalesManager and RegionManager. They can be used them to secure SharePoint objects just like the code example in the FillEntityTypes() reference topic used the ASP.NET roles to do the same thing.

You also must implement the FillResolve() method that takes a SPClaim parameter. This method is used to resolve one single claim to verify the existence of the claim. The People Picker first search the claims using FillSearch() method. Once the user picks one of the claims, the People Picker calls FillResolve() to verify it again.

Sample code provided by: Andy Li, Microsoft Corporation.

Examples


// Returns true if you support claim search in the People Picker control.
public override bool SupportsSearch
{
    get { return true; }
}
protected override void FillSearch(Uri context, string[] entityTypes, string searchPattern, string hierarchyNodeID, int maxCount, SPProviderHierarchyTree searchTree)
        {
            if (searchPattern.ToUpper() == "SALESMANAGER")
            {
                PickerEntity entity = CreatePickerEntity();
                entity.Claim = CreateClaim(CRMClaimType.Role, CRMRoleValue.SalesManager, Microsoft.IdentityModel.Claims.ClaimValueTypes.String);
                entity.Description = CRMRoleValue.SalesManager;
                entity.DisplayText = CRMRoleValue.SalesManager;
                entity.EntityData[PeopleEditorEntityDataKeys.DisplayName] = CRMRoleValue.SalesManager;
                entity.EntityType = SPClaimEntityTypes.FormsRole;
                entity.IsResolved = true;
                searchTree.AddEntity(entity);
            }
            if (searchPattern.ToUpper() == "REGIONMANAGER")
            {
                PickerEntity entity = CreatePickerEntity();
                entity.Claim = CreateClaim(CRMClaimType.Role, CRMRoleValue.RegionManager, Microsoft.IdentityModel.Claims.ClaimValueTypes.String);
                entity.Description = CRMRoleValue.RegionManager;
                entity.DisplayText = CRMRoleValue.RegionManager;
                entity.EntityData[PeopleEditorEntityDataKeys.DisplayName] = CRMRoleValue.RegionManager;
                entity.EntityType = SPClaimEntityTypes.FormsRole;
                entity.IsResolved = true;
                searchTree.AddEntity(entity);
            }
        }

See Also

Reference

SPClaimProvider Class

SPClaimProvider Members

Microsoft.SharePoint.Administration.Claims Namespace