From b6395d9a7a463999e30eb9907454334f75a1f0b7 Mon Sep 17 00:00:00 2001 From: Henry Tran Date: Wed, 31 Jan 2024 23:45:11 +0100 Subject: [PATCH 1/2] Added gMSA support --- README.md | 24 ++++++++++++++++++++++++ lib/daemon.js | 2 ++ lib/winsw.js | 5 ++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0c0e284..500d2f6 100644 --- a/README.md +++ b/README.md @@ -245,6 +245,30 @@ svc.sudo.password = 'password'; ... ``` + + +**app.js** + +To use Group Managed Service Accounts, append `$` to the end of account name and specify `svc.logOnAs.gmsa = true` + + +```js +var Service = require('node-windows').Service; + +// Create a new service object +var svc = new Service({ + name:'Hello World', + script: require('path').join(__dirname,'helloworld.js'), + allowServiceLogon: true +}); + +svc.logOnAs.domain = 'mydomain.local'; +svc.logOnAs.account = 'username_$'; +svc.logOnAs.gmsa = true; +... +``` + + ### Depending on other services The service can also be made dependant on other Windows services. diff --git a/lib/daemon.js b/lib/daemon.js index e4f90b8..b5367cb 100644 --- a/lib/daemon.js +++ b/lib/daemon.js @@ -402,6 +402,7 @@ var daemon = function (config) { * svc.logOnAs.account = 'username'; * svc.logOnAs.password = 'password'; * ... + * * * Both the account and password must be explicitly defined if you want the service to log on as that user, * otherwise the Local System account will be used. @@ -410,6 +411,7 @@ var daemon = function (config) { enumerable: false, writable: true, configurable: false, + gmsa: false, value: { account: null, password: null, diff --git a/lib/winsw.js b/lib/winsw.js index 03b5a85..f9a1bde 100644 --- a/lib/winsw.js +++ b/lib/winsw.js @@ -125,9 +125,12 @@ console.log({loc: 'winsw.js ~line 77', xml, config}) var serviceaccount = [ { domain: config.logOnAs.domain || 'NT AUTHORITY' }, { user: config.logOnAs.account || 'LocalSystem' }, - { password: config.logOnAs.password || '' } ] + if(!config.logOnAs.gmsa){ + serviceaccount.push({ password: config.logOnAs.password || '' }) + } + if (config.allowServiceLogon) { serviceaccount.push({ allowservicelogon: 'true' }) } From 2e0fcd8e876ea6d9af13436cca2793c205af345a Mon Sep 17 00:00:00 2001 From: Henry Tran Date: Thu, 1 Feb 2024 00:13:53 +0100 Subject: [PATCH 2/2] Removed unnecessary newlines --- README.md | 2 -- lib/daemon.js | 1 - 2 files changed, 3 deletions(-) diff --git a/README.md b/README.md index 500d2f6..3a802a8 100644 --- a/README.md +++ b/README.md @@ -245,8 +245,6 @@ svc.sudo.password = 'password'; ... ``` - - **app.js** To use Group Managed Service Accounts, append `$` to the end of account name and specify `svc.logOnAs.gmsa = true` diff --git a/lib/daemon.js b/lib/daemon.js index b5367cb..2d62b3d 100644 --- a/lib/daemon.js +++ b/lib/daemon.js @@ -402,7 +402,6 @@ var daemon = function (config) { * svc.logOnAs.account = 'username'; * svc.logOnAs.password = 'password'; * ... - * * * Both the account and password must be explicitly defined if you want the service to log on as that user, * otherwise the Local System account will be used.