docs: def impersonate_sid(sid, session_id=None, privs=None):
      '''
      Find an existing process token for the given sid and impersonate the token.
      '''
      for tok in enumerate_tokens(sid, session_id, privs):
          tok = dup_token(tok)
          elevate_token(tok)
          if win32security.ImpersonateLoggedOnUser(tok) == 0:
              raise WindowsError("Impersonation failure")  # pylint: disable=undefined-variable
          return tok
      raise WindowsError("Impersonation failure")