如果我在STRING中有一个用户名帐户,我该如何检查是否是管理员?
我正在寻找类似的东西:
Dim user as string = "test"
Dim isAdmin as Boolean = false
isAdmin = user.IsInRole(WindowsBuiltInRole.Administrator)
我必须检查ISN'当前用户的用户。
答案 0 :(得分:1)
您可以尝试下面的内容;
Imports System.Security.Principal
Dim W_Id = WindowsIdentity.GetCurrent()
Dim WP = new WindowsPrincipal(W_Id)
Dim isAdmin as Boolean = WP.IsInRole(WindowsBuiltInRole.Administrator)
要么将其称为onLoad(),要么将其全部包含在一个函数中,您可以在整个代码中调用它。