Skip to content

Commit

Permalink
Merge pull request chucknorris#2 from davidduffett/master
Browse files Browse the repository at this point in the history
Fix for how passwords are sent to NServiceBus.Host
  • Loading branch information
laazyj committed Aug 2, 2011
2 parents 96fc085 + 8484908 commit 25dc727
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public LocalNServiceBusHostTask(string exeName, string location, string instance
{
string args = string.IsNullOrEmpty(instanceName)
? ""
: " /instance:" + instanceName;
: " /instance:\"{0}\"".FormatWith(instanceName);

if (username != null && password != null)
{
Expand All @@ -38,9 +38,7 @@ public LocalNServiceBusHostTask(string exeName, string location, string instance
if (shouldPromptForPassword(username, password))
pass = _prompt.Prompt("Win Service '{0}' For User '{1}' Password".FormatWith(exeName, username));

args += " /username:{0}".FormatWith(user);
if (!string.IsNullOrEmpty(pass))
args += " /password:{0}".FormatWith(pass);
args += " /userName:\"{0}\" /password:\"{1}\"".FormatWith(user, pass);
}

if (!string.IsNullOrEmpty(serviceName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ public class RemoteNServiceBusHostTask :
public RemoteNServiceBusHostTask(string exeName, string location, string instanceName, PhysicalServer site, string username, string password, string serviceName, string displayName, string description)
{
string args = string.IsNullOrEmpty(instanceName)
? ""
: " /instance:" + instanceName;
? ""
: " /instance:\"{0}\"".FormatWith(instanceName);

if (username != null && password != null)
{
var user = username;
var pass = password;
if (username.ShouldPrompt())
user = _prompt.Prompt("Win Service '{0}' UserName".FormatWith(exeName));
if (password.ShouldPrompt())
if (shouldPromptForPassword(username, password))
pass = _prompt.Prompt("Win Service '{0}' For User '{1}' Password".FormatWith(exeName, username));

args += " /username:{0} /password:{1}".FormatWith(user, pass);
args += " /userName:\"{0}\" /password:\"{1}\"".FormatWith(user, pass);
}

if (!string.IsNullOrEmpty(serviceName))
Expand Down Expand Up @@ -73,5 +73,10 @@ public override DeploymentResult Execute()
Logging.Coarse("[nservicebushost] Installing a remote NServiceBus.Host service");
return _task.Execute();
}

private bool shouldPromptForPassword(string username, string password)
{
return !WindowsAuthentication.IsBuiltInUsername(username) && password.ShouldPrompt();
}
}
}

0 comments on commit 25dc727

Please sign in to comment.