5
SharePoint 如何判断当用户属于SharePoint Group
source link: https://www.cnblogs.com/jianyus/p/15750598.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
SharePoint 如何判断当用户属于SharePoint Group
前言
最近在开发的时候,需要去判断当前用户在哪个组里,然后,发现了下面的方法。
正文
完整的代码在下面,请求以后会返回当前用户所有的组。
$.ajax({ url: siteUrl + "/_api/web/currentuser/?$expand=groups", method: "GET", headers: { "Accept": "application/json; odata=verbose" }, success: function (data) { console.log(JSON.stringify(data)); }, error: function (data) { console.log(JSON.stringify(data)); } });
但是,这个方法有个问题,如果当前用户是以AD Group的方式存在于SharePoint Group,是判断不出来的,这就比较恶心了。
然后,又找了SharePoint Plus 这个插件,里面有个方法叫做isMember可以判断用户是否属于某个组,这个亲测支持AD Group的方式,但是,不能一下取到所有组。
结束语
开发这个事儿,可能很多时候真的是十全九美,好吧,大家参考一下把。如果大家发现了更好的办法,记得给我留言哈~
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK