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

a 夏天 提交于 2019-12-23 21:06:01

问题


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

回答1:


(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.




回答2:


I'm not sure if this is relevant but Matt Burton added the following commit recently:

  • added command line credential support to host

I've yet to try it but my question (1) may now be irrelevant.



来源:https://stackoverflow.com/questions/1487800/when-installing-a-generic-host-as-a-service-in-nservicebus-how-do-i-provide-val

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!