我想做一个函数来确定一个用户,其ID是通过参数传递的是一个管理员。我能为当前登录做到这一点与用户 -看看用户是否是Windows 7中的管理员?
public static bool IsAuthorizedUser()
{
WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}
,但我想检查中传递的任何用户因此签名会变为
public static bool IsAuthorizedUser(string username_to_check)
我怎样才能做到这一点?任何帮助表示赞赏。
你显然需要知道有问题的用户的密码,看看这个:http://blogs.msdn.com/b/saurabhkv/archive/2008/05/29/windowsidentity-impersonation - 使用-C-code.aspx –
和这一个了http://msdn.microsoft.com/en-us/library/w070t6ka.aspx –
有什么办法来解决呢?这就是我想要的。我只是想检查用户是否是管理员。我不明白为什么我不得不知道他们的密码.. – Sterling