感谢测试,我现在才知道这个BUG,这是因为_SeIsUserAdminEx函数内部没有检查用户是否存在 而引发的错误。改用以下代码判断是否具有管理员权限:
#include <lsasecur.au3>
Const $USER_TEST = "abc"
Local $pSid = _SeLookupAccountName($USER_TEST)
If $pSid = 0 Then
MsgBox(48, "Error", _SeFormatMsg())
Exit
EndIf
Local $pAdminsSid = _SeGetWellKnownAccountSid($SE_WELLKNOWN_ADMINS)
Local $pDacl = _SeSetEntriesInAcl1($pAdminsSid, 1, $SE_GRANT_ACCESS, $SE_NO_INHERITANCE)
If _SeGetEffectiveRightsFromAcl($pDacl, $pSid) Then
MsgBox(48, "OK", StringFormat("'%s' is an administrator.", $USER_TEST))
Else
MsgBox(48, "OK", StringFormat("'%s' is not an administrator.", $USER_TEST))
EndIf
_SeLocalFree($pDacl)
_SeFreeSid($pAdminsSid)
_SeHeapFree($pSid)
|