WPF窗口应用程序中基于角色的访问 [英] Role based access in WPF window application

查看:68
本文介绍了WPF窗口应用程序中基于角色的访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个WPF窗口应用程序,因为我必须根据为不同类型的用户定义的角色来启用/禁用Insert,Update,Delate按钮.
例如-管理员被授权进行所有操作,即插入/更新/删除,而普通用户只能被授权查看可用数据.

任何帮助都是可观的....

感谢和问候

Hi,

I have a WPF window application, In that I have to Enable/Disable the Insert,Update,Delate buttons based on roles defined for different type of users.
For example - Admin is authorized for all operations i.e Insert/update/delete while a normal user can be authorized only to view the available data.

Any help is appreciable....

Thanks and Regards

推荐答案

http://msdn.microsoft.com/ru-ru/library/system.security.principal.windowsidentity.aspx[^]

use this class to get current user''s groups and roles.

WindowsIdentity currentIdentity = WindowsIdentity.GetCurrent();

WindowsPrincipal principal = new WindowsPrincipal(currentIdentity);

if(principal.IsInRole(WindowsBuiltInRole.Administrator))
{
     //enable button here
}


这篇关于WPF窗口应用程序中基于角色的访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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