你跟踪一下看看MyIdentity.Name是什么?在看看MyIdnetity.IsSystem是不是true?
如果回答是肯定的,那就是你的“User“不正确,IsInRole中的参数必须写成 xxxx\User的形式,或者WindowsBuiltInRole枚举的成员,或者对应该枚举的整型。
如果回答是肯定的,那就是你的“User“不正确,IsInRole中的参数必须写成 xxxx\User的形式,或者WindowsBuiltInRole枚举的成员,或者对应该枚举的整型。
解决方案 »
- wince 窗口重绘的问题
- C#初学者的问题,删除(listView)Acess数据库中的数据
- 关于在panel上的picturebox绘图的问题,刷新严重,请教办法,附代码
- TcpClient异步第一次连接服务器后,在向服务器发送消息失效.
- 如何加载xml到treeview中,并任意修改树结构后再写到xml文件中?
- 生成动态控件的排列问题(关于control.dock)
- [急]SQL(2005)能否直接调用VS2003写的一个类库 / Webservice
- ajaxpro难题,需要高手帮忙
- 如何让自制的选项功能生效,使用程序按选项设置运行?
- 页面离开时,怎样产生事件???
- 誰有xceed zip for .net 2.0的注冊碼呀
- 下拉列表框问题
AppDomain myDomain = Thread.GetDomain(); myDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
WindowsPrincipal myPrincipal = (WindowsPrincipal)Thread.CurrentPrincipal;
Console.WriteLine("{0} belongs to: ", myPrincipal.Identity.Name.ToString()); Array wbirFields = Enum.GetValues(typeof(WindowsBuiltInRole)); foreach (object roleName in wbirFields)
{
try
{
Console.WriteLine("{0}? {1}.", roleName,
myPrincipal.IsInRole((WindowsBuiltInRole)roleName));
}
catch (Exception)
{
Console.WriteLine("{0}: Could not obtain role for this RID.",
roleName);
}
}
IsInRole(“xxxx\User”)这样的参数形式我也试过了
但是返回的结果还是false!!