def _ace_to_text(ace, objectType):
 dc = daclConstants()
 objectType = dc.getObjectTypeBit(objectType)
 try:
  userSid = win32security.LookupAccountSid('', ace[2])
  if userSid[1]:
   userSid = '{1}\\{0}'.format(userSid[0], userSid[1])
  else:
   userSid = '{0}'.format(userSid[0])
 except Exception:
  userSid = win32security.ConvertSidToStringSid(ace[2])
 tPerm = ace[1]
 tAceType = ace[0][0]
 tProps = ace[0][1]
 tInherited = ''
 for x in dc.validAceTypes:
  if (dc.validAceTypes[x]['BITS'] == tAceType):
   tAceType = dc.validAceTypes[x]['TEXT']
   break
 for x in dc.rights[objectType]:
  if (dc.rights[objectType][x]['BITS'] == tPerm):
   tPerm = dc.rights[objectType][x]['TEXT']
   break
 if ((tProps & win32security.INHERITED_ACE) == win32security.INHERITED_ACE):
  tInherited = '[Inherited]'
  tProps = (tProps ^ win32security.INHERITED_ACE)
 for x in dc.validPropagations[objectType]:
  if (dc.validPropagations[objectType][x]['BITS'] == tProps):
   tProps = dc.validPropagations[objectType][x]['TEXT']
   break
 return '{0} {1} {2} on {3} {4}'.format(userSid, tAceType, tPerm, tProps, tInherited)

def _ace_to_text ( ace , objectType ) : dc = daclConstants ( ) objectType = dc . getObjectTypeBit ( objectType ) try : userSid = win32security . LookupAccountSid ( '' , ace [ 2 ] ) if userSid [ 1 ] : userSid = '{1}\\{0}' . format ( userSid [ 0 ] , userSid [ 1 ] ) else : userSid = '{0}' . format ( userSid [ 0 ] ) except Exception : userSid = win32security . ConvertSidToStringSid ( ace [ 2 ] ) tPerm = ace [ 1 ] tAceType = ace [ 0 ] [ 0 ] tProps = ace [ 0 ] [ 1 ] tInherited = '' for x in dc . validAceTypes : if ( dc . validAceTypes [ x ] [ 'BITS' ] == tAceType ) : tAceType = dc . validAceTypes [ x ] [ 'TEXT' ] break for x in dc . rights [ objectType ] : if ( dc . rights [ objectType ] [ x ] [ 'BITS' ] == tPerm ) : tPerm = dc . rights [ objectType ] [ x ] [ 'TEXT' ] break if ( ( tProps & win32security . INHERITED_ACE ) == win32security . INHERITED_ACE ) : tInherited = '[Inherited]' tProps = ( tProps ^ win32security . INHERITED_ACE ) for x in dc . validPropagations [ objectType ] : if ( dc . validPropagations [ objectType ] [ x ] [ 'BITS' ] == tProps ) : tProps = dc . validPropagations [ objectType ] [ x ] [ 'TEXT' ] break return '{0} {1} {2} on {3} {4}' . format ( userSid , tAceType , tPerm , tProps , tInherited )
helper function to convert an ace to a textual representation .