[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

@ -13,11 +13,15 @@ BEGIN
IDS_USAGE09 " /profile Legt fest, dass das Benutzerprofil geladen werden soll.\n"
IDS_USAGE10 " Dies ist die Standardeinstellung.\n"
IDS_USAGE11 " /env Verwendet die aktuelle Umgebung statt der des Benutzers.\n"
IDS_USAGE12 " /netonly Noch nicht implementiert.\n"
IDS_USAGE13 " /savecred Noch nicht implementiert.\n"
IDS_USAGE14 " /smartcard Noch nicht implementiert.\n"
IDS_USAGE15 " /user <Benutzername> muss in der Form Benutzer@Domäne oder\n Domäne\\Benutzer angegeben werden\n"
IDS_USAGE16 " Programm Befehlszeile einer ausführbaren Datei. Siehe unten\n aufgeführte Beispiele.\n\n"
IDS_USAGE12 " /netonly Falls Anmeldeinformationen nur für den Remotezugriff\n"
IDS_USAGE13 " gültig sind.\n"
IDS_USAGE14 " /savecred Noch nicht implementiert.\n"
IDS_USAGE15 " /smartcard Noch nicht implementiert.\n"
IDS_USAGE16 " /user <Benutzername> muss in der Form Benutzer@Domäne oder\n Domäne\\Benutzer angegeben werden\n"
IDS_USAGE17 " Programm Befehlszeile einer ausführbaren Datei. Siehe unten\n aufgeführte Beispiele.\n\n"
IDS_USAGE18 "Beispiel:\n"
IDS_USAGE19 "> runas /noprofile /user:mymachine\\administrator cmd\n\n"
IDS_USAGE20 "HINWEIS: /profile is nicht kompatibel mit /netonly.\n"
IDS_START "Es wird versucht, %s als Benutzer ""%s\\%s"" zu starten...\n"
IDS_RUN_ERROR "RUNAS-FEHLER: %s kann nicht ausgeführt werden\n"

View file

@ -13,11 +13,15 @@ BEGIN
IDS_USAGE09 " /profile specifies that the user's profile should be loaded.\n"
IDS_USAGE10 " This is the default.\n"
IDS_USAGE11 " /env to use current environment instead of user's.\n"
IDS_USAGE12 " /netonly Not implemented yet.\n"
IDS_USAGE13 " /savecred Not implemented yet.\n"
IDS_USAGE14 " /smartcard Not implemented yet.\n"
IDS_USAGE15 " /user <UserName> should be in form USER@DOMAIN or DOMAIN\\USER\n"
IDS_USAGE16 " program command line for EXE. See below for examples\n\n"
IDS_USAGE12 " /netonly use if the credentials specified are for remote\n"
IDS_USAGE13 " access only.\n"
IDS_USAGE14 " /savecred Not implemented yet.\n"
IDS_USAGE15 " /smartcard Not implemented yet.\n"
IDS_USAGE16 " /user <UserName> should be in form USER@DOMAIN or DOMAIN\\USER\n"
IDS_USAGE17 " program command line for EXE. See below for examples\n\n"
IDS_USAGE18 "Example:\n"
IDS_USAGE19 "> runas /noprofile /user:mymachine\\administrator cmd\n\n"
IDS_USAGE20 "NOTE: /profile is not compatible with /netonly.\n"
IDS_START "Attempting to start %s as user ""%s\\%s""...\n"
IDS_RUN_ERROR "RUNAS ERROR: Unable to run %s\n"

View file

@ -14,7 +14,11 @@
#define IDS_USAGE14 7013
#define IDS_USAGE15 7014
#define IDS_USAGE16 7015
#define IDS_USAGE_MAX IDS_USAGE16
#define IDS_USAGE17 7016
#define IDS_USAGE18 7017
#define IDS_USAGE19 7018
#define IDS_USAGE20 7019
#define IDS_USAGE_MAX IDS_USAGE20
#define IDS_START 7100
#define IDS_RUN_ERROR 7101

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);