Sunday, November 23, 2014

Sharepoint Custom Claims provider - Fill Resolve method implementation.


In order to have the fillresolve methods to be triggered, you need to have the property SupportsResolve to true.

We will have 2 overload methods of fillResolve in your custom claims provider. You need to implement both of these methods.

protected override void FillResolve(Uri context, string[] entityTypes, string resolveInput, List<Microsoft.SharePoint.WebControls.PickerEntity> resolved) - This method will be called when you enter name in the text box and click resolve.

and

protected override void FillResolve(Uri context, string[] entityTypes, SPClaim resolveInput, List<Microsoft.SharePoint.WebControls.PickerEntity> resolved) - This method will be called when you enter name in the people picker and click add, it will call fillresolve as it needs to resolve the name as soon as we have an entry in textbox.


You need to implement the Picker entity; Use SPClaim constructor instead of CreateClaim constructor.

private PickerEntity GetPickerEntity(string ClaimValue, string type)
{
PickerEntity pe = CreatePickerEntity();
 
/* in my case, emailaddress is the identity claim. Make sure that the last parameter TrustedProvider is correct, otherwise name resolution will not be correct. */

pe.Claim = new SPClaim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress", ClaimValue, ClaimValueType, SPOriginalIssuers.Format(SPOriginalIssuerType.TrustedProvider, "Trusted User"));  

pe.EntityData[PeopleEditorEntityDataKeys.AccountName] = ClaimValue;
pe.EntityData[PeopleEditorEntityDataKeys.Email] = ClaimValue;
pe.DisplayText = ClaimValue;
pe.EntityData[PeopleEditorEntityDataKeys.DisplayName] = ClaimValue;
pe.EntityType = SPClaimEntityTypes.User;
pe.IsResolved = true;
return pe;
}

More Information

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.claims.spclaim.spclaim.aspx

http://blogs.technet.com/b/speschka/archive/2010/05/25/replacing-the-out-of-box-name-resolution-in-sharepoint-2010-part-2.aspx

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.claims.spclaimprovider.fillsearch.aspx

No comments:

Post a Comment