如何从用户字段LookupId获取用户 [英] How to get user from User field LookupId

查看:109
本文介绍了如何从用户字段LookupId获取用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在sharepoint在线上有一个列表.在此列表中,我有一个人员字段.

I have a list in sharepoint online. And in this list, i have a person field.

当我调用API端点以获取列表中的所有项目时,我将获得人员字段的LookupId值.

When i call the API endpoint to get all the items in the list, i get an LookupId value for the person field.

我试图通过使用lookupid的值来吸引用户,但由于ID无法识别,因此无法正常工作.

I tried to get the user by using the value of the lookupid, but it don't work because the id is not recognized.

lookupid是一个int(例如21)而不是guid.

The lookupid is a int (eg: 21) instead of a guid.

人员字段的配置或我对Microsoft Graph API的调用中是否缺少某些内容?

Is there something missing in the configuration of the person field or in my calls to Microsoft Graph API ?

推荐答案

当用户首次登录SharePoint网站集时,将在隐藏的用户信息列表中创建ListItem.PersonOrGroup字段中的LookupId引用此列表中的ListItem.SharePoint Online的用户信息列表的URL应为:

When a user signs into a SharePoint site collection for the first time, a ListItem is created in a hidden User Information List. The LookupId in a PersonOrGroup field refers to the ListItem in this list. The URL for the User Information List for SharePoint Online should be:

https://{yourTenant}.sharepoint.com/{yourSiteCollection}/_catalogs/users/detail.aspx

由于用户信息列表是通用的SharePoint列表,因此您可以通过Graph查询该列表.首先,获取用户信息列表的列表ID.获取列表ID的一种简单方法是通过Chrome浏览用户信息网站"的来源并搜索"listId".您应该找到这样的结果:

Since the User Information List is a generic SharePoint list, you can query the list via Graph. First, get the list id for the User Information List. An easy way to get the list id is to view the source for the User Information Site via Chrome and search for 'listId'. You should find a result like this:

"listId":"{yourListIdIsHere}"

复制ID.通过使用复制的ID,您的根站点的ID和LookupId,您可以在用户信息列表中获取ListItem:

Copy the id. By using the copied id, the id of your root site and the LookupId, you can get the ListItem in the User Information List:

https://graph.microsoft.com/v1.0/sites/{siteId}/lists/{pasteCopiedListId}/item/{lookUpId}?$expand=Fields

ListItem包含有关用户的信息,例如电子邮件,可用于标识Azure用户:

The ListItem contains information about the user, such as the email, which can be used to identify the Azure user:

https://graph.microsoft.com/v1.0/users/{eMail}

问题:如何从Microsoft Graph获取隐藏的用户信息列表?

如果您不想在Google Chrome浏览器中使用技巧"来获取ID,则可以使用另一种方式来获取网站.通常,如果要获取任何站点的ID,请致电:

If you do not want to use the 'trick' with Google Chrome to get the id, there is another way to get the site. Typically, if you want to get the id for any site, you would call:

https://graph.microsoft.com/v1.0/sites/{siteId}/lists

但是,即使包含隐藏的站点,也找不到用户信息列表的ID.我不知道为什么.另一个问题似乎是,您无法按列表名称过滤列表:

However, you will not find the id of the User Information List, even if you include hidden sites. I do not know why. An additional problem seems to be, that you cannot filter lists by their name:

https://graph.microsoft.com/v1.0/sites/{siteId}/lists?$filter=name eq 'users'

查询返回错误,表明不支持提供的filter语句.在不知道ID的情况下获取列表的唯一方法似乎是使用列表的displayName属性.但是,displayName基于您的本地化.因此,由于我来自德国,因此可以使用查询获取该网站:

The query returns an error, that the provided filter statement is not supported. The only way to get the list without knowing the id seems to by using the property displayName of the list. However, the displayName is based on your localization. So, since I am from Germany, I can get the site by using the query:

https://graph.microsoft.com/v1.0/sites/{siteId}/lists?$filter=displayName eq 'Benutzerinformationsliste'

您将需要使用本地化名称替换Benutzerinformationsliste.这将返回预期的结果:

You will need to replace Benutzerinformationsliste with your localized name. This returns the expected result:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('xxx')/lists(id,name,displayName)",
    "value": [
        {
            "@odata.etag": "\"xxx\"",
            "id": "xxx",
            "name": "users",
            "displayName": "Benutzerinformationsliste"
        }
    ]
}

如您所见,列表的名称为'users',所以为什么第一个过滤器语句不起作用对我来说还是一个谜.也许这里有人知道并且可以帮忙.

As you can see, the name of the list is 'users', so why the first filter statement does not work is a little mystery to me. Maybe someone here knows and can help out.

这篇关于如何从用户字段LookupId获取用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆