使用JSOM登录检查用户是Active Directory组的一部分 [英] check is logged in user is part of Active directory group using JSOM

查看:87
本文介绍了使用JSOM登录检查用户是Active Directory组的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以查询AD组以检查SharePoint 2013网站上的登录用户是否属于AD组或不使用JSOM/JQUERY?

Is there any way to query AD group to check if logged-in user on SharePoint 2013 site is part of AD group or not using JSOM/JQUERY?

关于

Ankit

推荐答案

据我所知,目前尚无API从客户端(JSOM/jQuery)检查广告组中的用户.

作为一种解决方法,您可以创建一个服务,以便可以从jQuery调用该服务.

这里有一个有关创建服务以供您参考的主题.

用于检查广告组中的用户.

using System.DirectoryServices.AccountManagement;  
  
protected bool CurrentUserIsMemberOfGroup(string groupName)  
{  
    string userLogin = SPContext.Current.Web.CurrentUser.LoginName;  
    // To get the right context, run with elevated privileges  
    SPSecurity.RunWithElevatedPrivileges(delegate()   
    {  
        var principalContext = new PrincipalContext(ContextType.Domain);  
        var userPrincipal = UserPrincipal.FindByIdentity(principalContext, System.DirectoryServices.AccountManagement.IdentityType.SamAccountName, userLogin);  
        var group = GroupPrincipal.FindByIdentity(principalContext , groupName);  
        return userPrincipal.IsMemberOf(group);   
    });  
}

此处是供您参考的主题.

http://www.sharepointpills.com/2011/09/check-if-sharepoint-user-is-member-of. html


这篇关于使用JSOM登录检查用户是Active Directory组的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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