2015-05-14 120 views
0

我在Azure的AD用户Azure的AD图形API无法访问Microsoft帐户

  1. 微软帐户用户
  2. 微软Azure Active Directory的用户

用户2始终工作在图形API调用,但不是用户1

https://graph.windows.net/tenantid/users/[email protected]?api-version=2013-04-05

(电子邮件实际上是URL编码为testmail%40hotmail.com)。 这给出了以下错误 “{\”odata.error \“:{\”code \“:\”Request_ResourceNotFound \“,\”message \“:{\”lang \“:\”en \ “value \”:\“Resource'[email protected]'不存在或其查询的引用属性对象不存在。”}}}“

有谁知道如何解决这个问题?

编辑: 我想通了,试图解决这个问题。我在上面的查询中使用UserPrincipal名称(.. users/[email protected]?..)。对于内置域帐户,userPricipal名称为[email protected](此工作方式),但对于Microsoft帐户userPrincipal名称为testmail_hotmail.com#EXT#@domain.com。这是在所有用户列表中给出的(https://graph.windows.net/tenantid/users?api-version=2013-04-05)。但即使当我在URL编码(testmail_hotmail.com%23EXT%23%40domain.com)之后将查询更改为'..users/testmail_hotmail.com#EXT#@ domain.com?'ofcourse时,它仍然不起作用。 Objectid总是适用于所有帐户(.. users/objectId?..)。

也尝试过其他的mails。可能是api错误,因为其他的mails是一个数组。 “https://graph.windows.net/tenantId/Users?$ filter = otherMails eq'testmail%40hotmail.com'& api-version = 2013-04-05”

所以问题依然存在。如果只有电子邮件在拨打电话时可用于MS账户(并非objectid),如何获取用户详细信息?

回答

0

您在发布的网址中缺少您的域名。它应该是

https://graph.windows.net/[your Azure AD domain]/users 

要获取用户的电子邮件地址,您需要在请求URL中添加用户的对象ID。因此,举例来说,得到它会是这样一个Azure的AD用户:

https://graph.windows.net/[your Azure AD domain]/users/[object ID of user]/mail 

对于用户从微软帐户采购目录,邮件属性为null。所以,你将在otherMails财产这样看:

https://graph.windows.net/[your Azure AD domain]/users/[object ID of user]/otherMails 

如果你想使用用户的UPN访问完整的用户帐号,你可以做到这一点从Azure的AD来源的用户。例如,对于一个租户域contoso.com和一个UPN [email protected]用户,查询应该是这样的:

https://graph.windows.net/contoso.com/users/[email protected] 

这并不适用于微软帐户来源的用户。对于这些帐户,UPN包含打破查询的字符(例如#,。)。您可以通过UPN进行过滤,但使用来自Microsoft帐户的用户使用的命名约定。假设您有一位用户,其电子邮件地址为jayhamlin @ yahoo。com在您的目录中。 UPN会像jayhamlin_yahoo.com#EXT#@contoso.com。所以,你可以使用一个过滤器并查找UPN的这样的第一部分:

https://graph.windows.net/contoso.com/users?api-version=2013-11-08&$filter=startswith(userPrincipalName, 'jayhamlin_yahoo') 

您可以轻松地探索使用https://graphexplorer.cloudapp.net目录中的图形API和对象属性。

+0

一些如何在我添加到此页面时消失。更正 –

+0

我明白了。你仍然没有正确地浏览图表。我会更新我的答案。 –

+0

因此无法以这种方式检索MS帐户(userPrincipalName)? https://graph.windows.net/tenantid/users/[email protected]?api-version=2013-04-05。因为打电话时我只有电子邮件ID。没有objectid –

-1

该过滤器可以工作,但您也可以过滤其他邮件。您的原始查询不起作用,因为其他邮件是多值属性 - 所以您需要使用“any”:

https://graph.windows.net/tenantId/users?api-version=1.5& $ filter = otherMails/any(x:startswith(x,'testmail @ hotmail.com' ))

你什么时候使用这个查找?用户是否已登录或针对某些人采摘场景?

干杯,

+0

这是为了获得签署的更多细节。 –

相关问题