Skip to main content
 首页 » 编程设计

python之如何在 python 中使用 GetEffectiveRightsFromAcl 函数

2025年01月19日9java哥

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