Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When installing a Generic Host as a service in NServiceBus, how do I provide valid credentials?

Imagine I create a .bat file in the following directory:

\trunk\Samples\PubSub\

@ECHO OFF
ECHO installing Subscriber 1
Subscriber1\bin\Debug\NServiceBus.Host.exe /install
pause
ECHO installing Subscriber 2
Subscriber2\bin\Debug\NServiceBus.Host.exe  /install
pause
ECHO starting Subscriber services
net start Subscriber1.EndPointConfig_v1.0.0.0
net start Subscriber2.EndPointConfig_v1.0.0.0
pause

I get prompted for a username and password, but using my own credentials I get an exception as follows:

An exception occurred during the Install phase. System.ComponentModel.Win32Exception: The account name is invalid or does not ex ist, or the password is invalid for the account name specified

  1. what credentials can I pass to get this to work?

  2. can I configure credentials as command line arguments to NServiceBus.Host.exe or run as 'Local System Account'?

Note:

My research so far suggests that (2) may be something that TopShelf supports via it's IInstallationConfiguration

I'm doing this on a Vista machine with MSMQ installed already.

The PubSub sample runs as expected if I just run the subscriber instances as console apps (i.e. like this):

@ECHO OFF
ECHO starting Subscriber 1
Subscriber1\bin\Debug\NServiceBus.Host.exe NServiceBus.Integration
pause
like image 402
rohancragg Avatar asked Dec 05 '25 17:12

rohancragg


1 Answers

(2.) can I configure credentials as command line arguments to NServiceBus.Host.exe or run as 'Local System Account'?

After digging around in TopShelf and NSB source code I discovered that this is pretty simple:

For anyone who's interested - this is something the TopShelf implements with IRunnerConfigurator.RunAsLocalSystem. NServiceBus calls this method if you add the marker interface ISpecify.ToRunAsLocalSystem

So the answer is to add ISpecify.ToRunAsLocalSystem to the list of interfaces implemented by the EndpointConfig class.

I didn't find an answer to:

(1.) what credentials can I pass to get this to work?

But now I don't really need one now as I'm happy enough to run the services as Local System.

like image 90
rohancragg Avatar answered Dec 08 '25 14:12

rohancragg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!