Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ServiceProcessInstaller fails with "No mapping between account names and security IDs was done"

I have an installer class using ServiceProcessInstaller. In the installer class in the constructor I add it to installers:

serviceProcessInstaller = new ServiceProcessInstaller();
serviceInstaller = new ServiceInstaller();

// Add Both Installers to Project Installers Collection to be Run
Installers.AddRange(new Installer[]
                                {
                                    serviceProcessInstaller,
                                    serviceInstaller
                                });

and in Install method I set the username and password:

public override void Install(IDictionary stateSaver)
{
    .... open the form, bla bla bla
    serviceProcessInstaller.Password = accountForm.txtPassword.Text;
    serviceProcessInstaller.Username = accountForm.txtServiceAccount.Text;
    serviceProcessInstaller.Account = ServiceAccount.User;
}

when I try to run it however, I get the very descriptive error message: "No mapping between account names and security IDs was done". What am I doing wrong?

EDIT: I tested that this error happens only when I install this component using msi package. It works just fine when I run InstallUtil against it.

like image 944
Grzenio Avatar asked Mar 13 '09 15:03

Grzenio


2 Answers

Found it finally: there seems to be a "feature" in ServiceProcessInstaller, where the code overwrites the values I provided explicitly with the values from the context. The MSI installer set the username to some crap (my company name), and ServiceProcessInstaller tried to install the service as this user and not the one explicitly provided by me. So the workaround is to set the correct values in the config:

public override void Install(IDictionary stateSaver)
{
    .... open the form, bla bla bla
    serviceProcessInstaller.Password = accountForm.txtPassword.Text;
    Context.Parameters["PASSWORD"] = accountForm.txtPassword.Text;
    serviceProcessInstaller.Username = accountForm.txtServiceAccount.Text;
    Context.Parameters["USERNAME"] = accountForm.txtServiceAccount.Text;
    serviceProcessInstaller.Account = ServiceAccount.User;
}
like image 193
Grzenio Avatar answered Sep 28 '22 17:09

Grzenio


Maybe its got something to do with your service account on you machine environment

  • http://www.shog9.com/log/archives/1-No-mapping-between-account-names-and-security-IDs-was-done.html
  • http://support.microsoft.com/kb/890737
  • http://bytes.com/groups/net-c/227254-serviceprocessinstaller-account-user-doesnt-work

Hope the help to understand your situation.

like image 40
abmv Avatar answered Sep 28 '22 17:09

abmv