基于用户的安全菜单项
在我正在编写的这个 winform 应用程序中,我想保护大多数用户的一个菜单项。它在月底运行,如果不小心运行则无法轻易退出。菜单选项会打开一个窗口,在处理之前提示用户输入一些信息。我不关心具体在哪里进行检查,但我想确保只有某些用户可以运行此功能。
谷歌搜索(关于我上面的问题标题)没有发现任何明显的东西。谁能告诉我谁登录了 Windows 以及如何检查他们是否获得授权?
On this winform application I am writing, I want to secure one menu item from most users. It runs a month-end and cannot be easily backed out if accidentally run. The menu option opens up a window to prompt the user for some information before processing. I don't care where exactly I do the check, but I want to be sure only certain users can run this function.
A Google search (on my question title above) didn't turn up anything obvious. Can anyone point me in a direction to pick up who is signed into Windows and how to check if they are authorized?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此页面有一些用于获取用户详细信息并检查它们的代码。
此代码:
返回当前用户名。您可以使用它来检查您的授权用户列表。
有关
WindowsIdentity
类的更多详细信息,请参阅 此处。它有一个 < code>Groups 属性,您可以使用它来检查组的成员身份,而不必检查单个用户。
This page has some code for getting user details and checking them.
This code:
returns the current user name. You could use this to check against your list of authorised users.
More details on the
WindowsIdentity
class can be found here.It has a
Groups
property which you could use to check for membership of a group rather than having to check individual users.