使用/users 时属性为空,但使用/me/contacts 时不为空 [英] Properties null when using /users but not when using /me/contacts
问题描述
从 https://graph.microsoft.com/v1.0/me/contacts
获取联系人时,我会获取用户的所有属性,例如:
When getting contacts from https://graph.microsoft.com/v1.0/me/contacts
I get all properties for a user, ex:
{
displayName: 'Joe Joeson',
jobTitle: 'Administrator',
department: 'HK',
mobilePhone: '09823987234',
businessPhones: '8934598743',
mail: 'joe@mail.com',
}
但是当我获得组织的所有用户时(使用 https://graph.microsoft.com/v1.0/users?$select=displayName,jobTitle,department,mobilePhone,businessPhones,mail,userType
) 同一个联系人没有获得某些属性,例如:
But when I get all users of the organization (with https://graph.microsoft.com/v1.0/users?$select=displayName,jobTitle,department,mobilePhone,businessPhones,mail,userType
) the same contact doesnt get some properties, ex:
{
displayName: 'Joe Joeson',
jobTitle: null,
department: null,
mobilePhone: null,
businessPhones: null,
mail: 'joe@mail.com',
}
为什么?是同一个联系人吗?还是我错过了什么?我应该以其他方式从组织中获取所有联系人吗?
Why? Its the same contact? Or am I missing something? Should I get all contacts from the organization in another way?
我已确认所有属性均在 https://portal.azure.com
I have confirmed that all properties are set in https://portal.azure.com
推荐答案
/contacts
和 /users
端点返回两个不同的实体.contact
实体表示来自当前用户的 Exchange 邮箱的 Outlook 联系人,而 user
实体表示来自租户的 Active Directory 实例的用户目录对象.
The /contacts
and /users
endpoints return two different entities. A contact
entity represents an Outlook Contact from the current user's Exchange mailbox whereas the a user
entity represents an User directory object from the tenant's Active Directory instance.
您看到两个不同结果的原因是您返回了两个不同的实体.第一个是 Outlook/Exchange 邮箱中的 Joe Joeson contact
,第二个是 Active Directory 中的 Joe Joeson user
.
The reason you're seeing two different results is because you're returning two different entities. The first is the Joe Joeson contact
from your Outlook/Exchange mailbox and the second is the Joe Joeson user
from Active Directory.
您从 /users
看到的信息较少的原因是您请求 Read all users' basic profile
(又名 User.ReadBasic.All
) 范围.此范围只能查看 user
资源的有限数量的属性:displayName
、givenName
、surname
、<代码>照片和邮件
.
The reason you're seeing less information from /users
is due to your requesting the Read all users' basic profiles
(aka User.ReadBasic.All
) scope. This scope can only see a limited number of properties from a user
resource: displayName
, givenName
, surname
, photo
, and mail
.
这篇关于使用/users 时属性为空,但使用/me/contacts 时不为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!