Support virtual service accounts.
[nssm.git] / settings.cpp
index f7346cb..11984bc 100644 (file)
@@ -1074,6 +1074,7 @@ int native_set_objectname(const TCHAR *service_name, void *param, const TCHAR *n
     That means the username is actually passed in the additional parameter.\r
   */\r
   bool localsystem = false;\r
+  bool virtual_account = false;\r
   TCHAR *username = NSSM_LOCALSYSTEM_ACCOUNT;\r
   TCHAR *password = 0;\r
   if (additional) {\r
@@ -1089,6 +1090,7 @@ int native_set_objectname(const TCHAR *service_name, void *param, const TCHAR *n
     username = (TCHAR *) well_known;\r
     password = _T("");\r
   }\r
+  else if (is_virtual_account(service_name, username)) virtual_account = true;\r
   else if (! password) {\r
     /* We need a password if the account requires it. */\r
     print_message(stderr, NSSM_MESSAGE_MISSING_PASSWORD, name);\r
@@ -1112,7 +1114,7 @@ int native_set_objectname(const TCHAR *service_name, void *param, const TCHAR *n
     HeapFree(GetProcessHeap(), 0, qsc);\r
   }\r
 \r
-  if (! well_known) {\r
+  if (! well_known && ! virtual_account) {\r
     if (grant_logon_as_service(username)) {\r
       if (passwordsize) SecureZeroMemory(password, passwordsize);\r
       print_message(stderr, NSSM_MESSAGE_GRANT_LOGON_AS_SERVICE_FAILED, username);\r