图 API Azure AD 中来宾用户的请求
Graph API requests for guest users in Azure AD
我想知道如何在 Azure AD 中为来宾用户进行图形 API 调用。我可以使用给定 here 的 API 示例为内部用户实现它,但相同的调用不适用于来宾用户。请求的方式有什么不同吗?
您租户中的来宾帐户的用户主体名称将与他们在其主租户中的 UPN 不同。您应该能够通过查询租户中的所有用户并找到具有 'modified' 用户主体名称(通常带有 "EXT".
的外部用户来查看这方面的证据
您可以在我们的演示租户中看到这方面的直接示例 here
"userPrincipalName": "djayachandran.cw_mmm.com#EXT#@GraphDir1.onmicrosoft.com",
您似乎需要使用其他未更改其旧 UPN 的属性来查询这些用户,例如 'mail' 属性。最终,您想找到您感兴趣的用户的 ObjectId,并将其用作查找用户信息的键。您应该能够从登录用户的令牌中获取对象 ID。
如果有帮助请告诉我!
谢谢,
肖恩·塔布里齐
@Shawn Tabrizi 上面的回答帮助我实现了我所需要的(获取登录用户的 Azure AD 组信息)。
为了从身份声明中获取用户 AD ObjectID,我使用了这个:
using System.Linq;
using System.Security.Claims;
namespace HealthcareEfficiencyService_webApp.Helpers
{
public class ClaimsHelper
{
private readonly static string objectIdClaimsType = "http://schemas.microsoft.com/identity/claims/objectidentifier";
public static string getAdObjectId(ClaimsIdentity claimsIdentity)
{
return claimsIdentity.Claims.FirstOrDefault(x => x.Type == objectIdClaimsType).Value;
}
}
}
我想知道如何在 Azure AD 中为来宾用户进行图形 API 调用。我可以使用给定 here 的 API 示例为内部用户实现它,但相同的调用不适用于来宾用户。请求的方式有什么不同吗?
您租户中的来宾帐户的用户主体名称将与他们在其主租户中的 UPN 不同。您应该能够通过查询租户中的所有用户并找到具有 'modified' 用户主体名称(通常带有 "EXT".
的外部用户来查看这方面的证据您可以在我们的演示租户中看到这方面的直接示例 here
"userPrincipalName": "djayachandran.cw_mmm.com#EXT#@GraphDir1.onmicrosoft.com",
您似乎需要使用其他未更改其旧 UPN 的属性来查询这些用户,例如 'mail' 属性。最终,您想找到您感兴趣的用户的 ObjectId,并将其用作查找用户信息的键。您应该能够从登录用户的令牌中获取对象 ID。
如果有帮助请告诉我! 谢谢, 肖恩·塔布里齐
@Shawn Tabrizi 上面的回答帮助我实现了我所需要的(获取登录用户的 Azure AD 组信息)。
为了从身份声明中获取用户 AD ObjectID,我使用了这个:
using System.Linq;
using System.Security.Claims;
namespace HealthcareEfficiencyService_webApp.Helpers
{
public class ClaimsHelper
{
private readonly static string objectIdClaimsType = "http://schemas.microsoft.com/identity/claims/objectidentifier";
public static string getAdObjectId(ClaimsIdentity claimsIdentity)
{
return claimsIdentity.Claims.FirstOrDefault(x => x.Type == objectIdClaimsType).Value;
}
}
}