def get_sid(principal):
 try:
  sid = salt.utils.win_functions.get_sid_from_name(principal)
 except CommandExecutionError:
  sid = principal
 try:
  sid = win32security.ConvertStringSidToSid(sid)
 except pywintypes.error:
  raise CommandExecutionError('Invalid user/group or sid: {0}'.format(principal))
 except TypeError:
  raise CommandExecutionError
 return sid

def get_sid ( principal ) : try : sid = salt . utils . win_functions . get_sid_from_name ( principal ) except CommandExecutionError : sid = principal try : sid = win32security . ConvertStringSidToSid ( sid ) except pywintypes . error : raise CommandExecutionError ( 'Invalid user/group or sid: {0}' . format ( principal ) ) except TypeError : raise CommandExecutionError return sid
converts a username to a sid .