隐藏基于广告组成员资格的控件 [英] Hide controls based on ad group membership

查看:90
本文介绍了隐藏基于广告组成员资格的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据AD群组成员资格使控件显示为隐藏。



我尝试过:



我对开发还很陌生。我正在使用studio 2015和.net 4.5在C#中构建一个webforms项目。该项目使用Windows身份验证。我找到了一种基于用户名显示\ hide控件的方法,我使用它来捕获:System.Web.HttpContext.Current.Request.LogonUserIdentity.Name.Split('\\')。我正在寻找一种检查组成员身份的方法,而不是必须更改代码来更改控件的用户权限。



.....例如,让我们说用户bobr在实验室用户AD组中,我想让Panel1可见。

I am trying to make controls visible\hidden based on AD group membership.

What I have tried:

I'm fairly new to development. I am building a webforms project in C#, using studio 2015, and .net 4.5. The project uses windows authentication. I have found a way to show\hide controls based on username, which I capture using: System.Web.HttpContext.Current.Request.LogonUserIdentity.Name.Split('\\'). I am looking for a way to check for group membership rather than having to change code to change user permissions on controls.

.....for example, lets say that user "bobr" is in "lab users" AD group, I want to make Panel1 visible.

推荐答案

你绝对不是第一个想做的人这个。您可以通过一些研究工作轻松找到答案。 Google为 asp.net show controls如果用户是管理员 [ ^ ]。
You're definitely not the first person to want to do this. You could have easily found the answer yourself with a little research effort. Google for "asp.net show controls if user is an administrator[^]".


感谢您的回复,但我实际上是在寻求帮助,而不是搜索词。我找到了答案。对于任何想要做同样事情的人来说,代码隐藏中的以下工作完美:



if(User.IsInRole(@domainname\groupname))

{

做点什么;

}
Thanks for the response, but I was actually looking for help, not a search term. I found answer myself. For anyone looking to do this same thing, the following in the code-behind worked perfectly:

if (User.IsInRole(@"domainname\groupname"))
{
do something;
}


这篇关于隐藏基于广告组成员资格的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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