[RUNAS] Support the /netonly option and improve the help text

This commit is contained in:
Eric Kohl 2022-02-26 18:57:57 +01:00
parent 977c129f33
commit 4109072bc8
4 changed files with 45 additions and 13 deletions

View file

@ -80,7 +80,7 @@ wmain(
LPCWSTR pszArg;
int i, result = 0;
BOOL bProfile = FALSE, bNoProfile = FALSE;
BOOL bEnv = FALSE;
BOOL bEnv = FALSE, bNetOnly = FALSE;
PWSTR pszUserName = NULL;
PWSTR pszDomain = NULL;
PWSTR pszCommandLine = NULL;
@ -122,6 +122,10 @@ wmain(
{
bProfile = TRUE;
}
else if (wcsicmp(pszArg, L"netonly") == 0)
{
bNetOnly = TRUE;
}
else if (wcsicmp(pszArg, L"noprofile") == 0)
{
bNoProfile = TRUE;
@ -224,7 +228,17 @@ wmain(
}
}
if (bProfile && bNoProfile)
/* Check for incompatible options */
if ((bProfile && bNoProfile) ||
(bProfile && bNetOnly))
{
Usage();
result = -1;
goto done;
}
/* Check for existing command line and user name */
if (pszCommandLine == NULL || pszUserName == NULL)
{
Usage();
result = -1;
@ -237,6 +251,12 @@ wmain(
if (bNoProfile)
dwLogonFlags &= ~LOGON_WITH_PROFILE;
if (bNetOnly)
{
dwLogonFlags |= LOGON_NETCREDENTIALS_ONLY;
dwLogonFlags &= ~LOGON_WITH_PROFILE;
}
DPRINT("User: %S\n", pszUserName);
DPRINT("Domain: %S\n", pszDomain);
DPRINT("CommandLine: %S\n", pszCommandLine);