简体   繁体   English

SharePoint 在线:使用 Office365-REST-Python-Client 库获取站点用户 ID

[英]SharePoint online: Get site user id using Office365-REST-Python-Client library

I am using SharePoint online and trying to get Site's user id using below REST API:我正在在线使用 SharePoint 并尝试使用以下 REST API 获取站点的用户 ID:

https://url/sites/list/_api/Web/siteusers#?$select=Id&$filter=substringof('|userloginname',LoginName) eq true

I've tried many libraries, but could successfully athenticate SharePoint online only with Office365-REST-Python-Client .我尝试了许多库,但只能使用Office365-REST-Python-Client成功地在线验证 SharePoint 。 So, would like to stick with same library.所以,想坚持使用同一个库。

I have gone through the examples provided on GitHub here .我已经浏览了 GitHub here上提供的示例。 Provided examples are only for list item.提供的示例仅适用于列表项。 But, I want to get site user details.但是,我想获取站点用户详细信息。

Has anyone done this with Office365-REST-Python-Client library?有没有人用Office365-REST-Python-Client库做到这一点?

Thanks in advance提前致谢

I have posted this question on Office365-REST-Python-Client and author has replied with answer.我已经在Office365-REST-Python-Client上发布了这个问题,作者已经给出了答案。 I just have to change a bit for my requirement.我只需要根据我的要求进行一些更改。 Below is the working code.下面是工作代码。 Hope it may be helpful to someone.希望它可能对某人有所帮助。

 client = ClientContext(url, context_auth)
 users = client.web.site_users\
                .filter("substringof('|{0}',LoginName) eq true".format('LoginName'))
 client.load(users)
 client.execute_query()
 for user in users:
      print('User : {0}, Id: {1}'.format(user.properties["Title"], user.properties["Id"]))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Office365-REST-Python-Client 复制 Sharepoint 中的文件 - Copy file in Sharepoint using Office365-REST-Python-Client 使用 Office365-REST-Python-Client 创建 SharePoint 列表时,如何在 ListCreationInformation object 中指定字段列表? - How do I specify a list of fields in a ListCreationInformation object, when using Office365-REST-Python-Client to create a SharePoint List? 使用 Office365-REST-Python-Client 下载 Sharepoint 文件响应 404 not found - Downloading Sharepoint file with Office365-REST-Python-Client responds 404 not found Python Sharepoint 库 Office365-REST-Python-Client 错误:401:网址未经授权:https://mydomain.sharepoint.com/sites/sample/_api/Web - Python Sharepoint library Office365-REST-Python-Client ERROR: 401: Unauthorized for url: https://mydomain.sharepoint.com/sites/sample/_api/Web Office365-REST-Python-客户端访问令牌问题 - Office365-REST-Python-Client Access Token issue 文件更新上的 Office365-REST-Python-Client 401 - Office365-REST-Python-Client 401 on File Update Office365-REST-Python-Client - 如何从 Sharepoint(MS-List)中读取超过 100 行 - Office365-REST-Python-Client - How to read more than 100 rows from a Sharepoint (MS-List) 使用 Python 访问 Office365 Sharepoint REST 端点(Python 的 Office365 Sharepoint REST 客户端) - Accessing Office365 Sharepoint REST EndPoints using Python (Office365 Sharepoint REST client for Python) 如何在 Sharepoint 的列表中上传多个项目在线使用 python office 365 rest - How to upload multiple items in a list in Sharepoint Online using python office 365 rest 在sharepoint office365 REST Python 客户端上传不同大小的文件 - Uploading files of different sizes on sharepoint office365 REST Python Client
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM