我正在尝试使用 win32security
模块。更准确地说,我需要使用 GetEffectiveRightsFromAcl()
( PyACL Object )。如何获取需要调用该函数的PyTRUSTEE受托者
?
我使用@eryksun 帮助得到了一些结果:
def print_permissions(mask, username):
print("Effective permissions for: ", username, "\n",
bool(mask & 0x00000001), "\tReadData\n",
bool(mask & 0x00000002), "\tWriteData\n",
bool(mask & 0x00000004), "\tAppendData\n",
bool(mask & 0x00000008), "\tReadEa\n",
bool(mask & 0x00000010), "\tWriteEa\n",
bool(mask & 0x00000020), "\tExecute\n",
bool(mask & 0x00000040), "\tDeleteChildn\n",
bool(mask & 0x00000080), "\tReadAttributes\n",
bool(mask & 0x00000100), "\tWriteAttributes\n",
bool(mask & 0x00010000), "\tDelete\n",
bool(mask & 0x00020000), "\tReadControl\n",
bool(mask & 0x00040000), "\tWriteDac\n",
bool(mask & 0x00080000), "\tWriteOwner\n",
bool(mask & 0x00100000), "\tSynchronize\n")
dacl = win32security.GetNamedSecurityInfo(
FILENAME,
win32security.SE_FILE_OBJECT,
win32security.DACL_SECURITY_INFORMATION).GetSecurityDescriptorDacl()
mask = dacl.GetEffectiveRightsFromAcl(
{'TrusteeForm': win32security.TRUSTEE_IS_NAME, 'TrusteeType': win32security.TRUSTEE_IS_USER,
'Identifier': username})
print_permissions(mask, username)
我是一名优秀的程序员,十分优秀!