gpt4 book ai didi

python - 如何在 python 中使用 GetEffectiveRightsFromAcl 函数?

转载 作者:太空宇宙 更新时间:2023-11-04 04:46:34 24 4
gpt4 key购买 nike

我正在尝试使用 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)

关于python - 如何在 python 中使用 GetEffectiveRightsFromAcl 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49431271/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com