Creating a Query for Claims

If you have created a custom claims provider, your custom claims provider must be able to query for the claims of a user.

The code sample below shows how to query for claims. When you query for claims, you must specify a UserName and AuthenticationMode, such as Windows or Forms, as search criteria. The code returns all the claims for the user for the channel specified in the RequestContext.

var query = new CommerceQuery<CommerceEntity, CommerceClaimsSearchBuilder>("CommerceClaim");

// set search criteria properties
query.SearchCriteria.UserName = “somebody”;
query.SearchCriteria.AuthenticationMode = "Windows";

// get commerce claims entities
CommerceResponse commerceClaimsResponse = OperationService.ProcessRequest(base.GetCurrentRequestContext(), query.ToRequest());

var queryResponse = commerceClaimsResponse.OperationResponses[0] as CommerceQueryOperationResponse;

See Also

Other Resources

Understanding Claims-Based Identity

Managing Authentication

Managing Authorization