def get_sid_string(principal):
 try:
  return win32security.ConvertSidToStringSid(principal)
 except TypeError:
  principal = get_sid(principal)
 try:
  return win32security.ConvertSidToStringSid(principal)
 except pywintypes.error:
  raise CommandExecutionError('Invalid principal {0}'.format(principal))

def get_sid_string ( principal ) : try : return win32security . ConvertSidToStringSid ( principal ) except TypeError : principal = get_sid ( principal ) try : return win32security . ConvertSidToStringSid ( principal ) except pywintypes . error : raise CommandExecutionError ( 'Invalid principal {0}' . format ( principal ) )
converts a pysid object to a string sid .