如何识别,当前用户是管理员..? [英] How to identify, Is current user a Administrator..?

查看:118
本文介绍了如何识别,当前用户是管理员..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



是否有任何注册表项可用于识别当前用户是否是管理员的天气...
我需要这样做以便我可以退出我的如果当前用户不是管理员,请进行设置。

如果还有其他方法可以重新安装我。

谢谢,


vishwas Srivastava

解决方案

您可以从WindowsPrincipal类获取此信息。

检查这篇文章的详细代码示例。

这里的诀窍是:

 myPrincipal.IsInRole(WindowsBuiltInRole.Administrator)? " True"  
" False"




您可以检查当前主体以检查当前用户是否是管理员。


Hi,

Is there any registry key using which I can identify that weather the current user is Administrator or not...
I need to do this so that i can exit my Setup if the current user is not an Admin.

Or recoment me if there is some other way to achieve the same.



Thanks,


vishwas Srivastava

解决方案

You can get this information from the WindowsPrincipal class.

Check out this article for a detailed code sample.

The trick here is in the line:

myPrincipal.IsInRole(  WindowsBuiltInRole.Administrator ) ? "True"
 : "False"
,

You can check the current principal to check to see if the current user is an administrator.


这篇关于如何识别,当前用户是管理员..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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