首页
讨论区
新职位
搜索论坛
什么's new
新职位
新的个人资料帖子
最新活动
会员
目前的访客
新的个人资料帖子
搜索个人资料帖子
VB.NET社区
登录
登记
什么's new
搜索
搜索
仅搜索标题
经过:
新职位
搜索论坛
Menu
Log in
Register
安装应用
安装
首页
讨论区
C#
安全
用户是活动目录组的成员?
您正在使用过期的浏览器。它可能无法正确显示此网站或其他网站。
您应该升级或使用
替代浏览器
.
回复主题
信息
<blockquote data-quote="jassie" data-source="post: 3071" data-attributes="member: 7348"><p>I have a C# 2010 desktop application where I have code setup to see if a user is a member of an active directory group. I am using WindowsIdentity to check the current users active directory group level. The following code is not working. Thus can you tell me how to what is wrong with the code below?</p><p>If you think the code listed below will not work, can you tell me how you would modify the code listed below?</p><p>If you do no see anything wrong, can you tell me what to suggest to the network people at my company to suggest to them what is wrong?</p><p>using ActiveDirectoryCommon; </p><p>using System; </p><p>using System.Collections.Generic; </p><p>using System.Linq; </p><p>using System.Windows.Forms; </p><p>using System.Collections.Specialized; </p><p>using System.Deployment.Application; </p><p>using System.Diagnostics; </p><p>using System.Reflection; </p><p>using System.Runtime.Remoting; </p><p>using System.IO; </p><p>using System.Web; </p><p>using System.Configuration; // required to obtain the values from the </p><p>ConfigurationManager.Appsettings in the app.config file </p><p>using System.Security.Principal; </p><p>using System.Threading; </p><p></p><p></p><p>namespace File_Reject </p><p>{ </p><p> static class Program </p><p> { </p><p> /// <summary> </p><p> internal static ActiveDirectoryUser CurUser; </p><p> [STAThread] </p><p> </p><p></p><p> static void Main() </p><p> { </p><p> try </p><p> { </p><p> Application.EnableVisualStyles(); </p><p> Application.SetCompatibleTextRenderingDefault(false); </p><p> CurUser = new ActiveDirectoryUser(); </p><p> if </p><p>(!Thread.CurrentPrincipal.IsInRole(Environment.UserDomainName + "\\" + ConfigurationManager.AppSettings["role_File_Upload"])) </p><p> { </p><p> MessageBox.Show("You do not have authortity to access File Transfer. Please contact your network administrator if you have any </p><p>questions.", "File Transfer Error", MessageBoxButtons.OK, MessageBoxIcon.Error); </p><p> return; </p><p> } </p><p> Application.Run(new FileReject()); </p><p> } </p><p> catch (Exception e) </p><p> { </p><p> //console.write(e.Message); </p><p> </p><p> } </p><p></p><p> } </p><p> } </p><p>} </p><p>---------- </p><p>using System; </p><p>using System.Collections.Generic; </p><p>using System.Linq; </p><p>using System.Text; </p><p>using System.Diagnostics; </p><p>using System.Reflection; </p><p>using System.IO; </p><p>using System.Threading; </p><p>using System.Web; </p><p>using System.Windows.Forms; </p><p>using System.Security.Principal; </p><p></p><p></p><p>namespace ActiveDirectoryCommon </p><p>{ </p><p> public class ActiveDirectoryUser </p><p> { </p><p> public ActiveDirectoryUser() </p><p> { </p><p> </p><p>AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); </p><p> Thread.CurrentPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent()); </p><p> } </p><p> } </p><p>} </p><p>-----------</p><p><?xml version="1.0"?> </p><p><configuration> </p><p></p><p> <appSettings> </p><p> <add key="role_File_Upload" value="File_Upload" /> </p><p> </appSettings> </p><p></configuration> </p><p>------------</p></blockquote><p></p>
Insert quotes…
确认
发表回复
首页
讨论区
C#
安全
用户是活动目录组的成员?
本网站使用Cookie来帮助个性化内容,调整您的体验并在注册时保持登录状态。
继续使用本网站,即表示您同意我们使用cookie。
接受
了解更多…
最佳
底部