为 SAML 断言获取 office365/azure 用户的不可变 ID

Getting immutableid of an office365/azure user for the SAML assertion

查看他们的文档 (https://docs.microsoft.com/en-us/azure/active-directory/hybrid/how-to-connect-fed-saml-idp),看起来我们在 SAML 断言中需要三样东西。

NameID -    The value of this assertion must be the same as the Azure AD user’s ImmutableID

IDPEmail -  The User Principal Name (UPN) is listed in the SAML response as an element with the name IDPEmail

Issuer -    Required to be a URI of the identity provider

我假设 idp 电子邮件只是用户的电子邮件,它对应于 Microsoft 图表 API 中的 userPrincipalName 字段。这个我们可以很容易地从API中获取。

我不确定 ImmutableID 是什么。

有没有办法使用微软的图表 API 来获取它?如果没有,我们如何获得它?

@nkpatel 是的,使用 Graph API,您可以获取不可变 ID 的值。如果使用 AAD 连接工具将用户对象从 On-Prem AD 同步到 AAD,用户对象将在图表 API 中具有名为“onPremisesImmutableId”的属性该用户的回复。

Eg: GET  https://graph.microsoft.com/beta/users/<UPN of the user>

您在此属性“onPremisesImmutableId”下找到的值将包含一个 Base64Encoded 值。默认情况下,本地用户的 ObjectGUID 是 base64Encoded 并存储在 Azure AD 中的“onPremisesImmutableId”中。

希望对您有所帮助。

是的,您可以从 Microsoft Graph Api 获得“onPremisesImmutableId”(如果已设置),使用以下端点

https://graph.microsoft.com/v1.0/users?$select=displayname,userprincipalname,givenname,onpremisesimmutableid

如果它为空,您可以使用以下 powershell 命令显式设置该 ImmutableId。

Set-MsolUser -UserPrincipalName abc@domain -ImmutableId 123

前提是域不能是联合域之一。如果它是联合的,则必须将其转换为“托管”。