次の方法で共有


ClaimsPrincipalFactory.FromHomeTenantIdAndHomeObjectId(String, String) Method

Definition

Instantiate a ClaimsPrincipal from a home account object ID and home tenant ID. This can be useful when the web app subscribes to another service on behalf of the user and then is called back by a notification where the user is identified by their home tenant ID and home object ID (like in Microsoft Graph Web Hooks).

public static System.Security.Claims.ClaimsPrincipal FromHomeTenantIdAndHomeObjectId (string homeTenantId, string homeObjectId);
static member FromHomeTenantIdAndHomeObjectId : string * string -> System.Security.Claims.ClaimsPrincipal
Public Shared Function FromHomeTenantIdAndHomeObjectId (homeTenantId As String, homeObjectId As String) As ClaimsPrincipal

Parameters

homeTenantId
String

Home tenant ID of the account.

homeObjectId
String

Home object ID of the account in this tenant ID.

Returns

A ClaimsPrincipal containing these two claims.

Examples

private async Task GetChangedMessagesAsync(IEnumerable<Notification> notifications)
{
 HttpContext.User = ClaimsPrincipalExtension.FromHomeTenantIdAndHomeObjectId(subscription.HomeTenantId,
                                                                     subscription.HomeUserId);
 foreach (var notification in notifications)
 {
  SubscriptionStore subscription =
          subscriptionStore.GetSubscriptionInfo(notification.SubscriptionId);
 string accessToken = await tokenAcquisition.GetAccessTokenForUserAsync(scopes);
 ...}
 }

Applies to