amesh
amesh

Reputation: 1319

How to connect mssql from msi installer through windows authentication

I am trying to create a web application set-up through visual studio set-up project. The database required for the application also being installed within the set-up as a custom action. The user is not providing any user name and password to connect the database. The set-up custom action need to connect database through windows authentication. But when it is tried to connect the database, it is throwing an exception - unable to connect database. Note: the web set-up is being installed with an elevated access. Please provide a solution to connect database through windows authentication from web set-up 'custom action'.

Upvotes: 0

Views: 700

Answers (2)

PhilDW
PhilDW

Reputation: 20790

The problem is most likely that custom actions in a VS Everyone install run with system account, not the installing user's account. I bet the DB doesn't allow SYSTEM to do things to it.

They run as system because that's what's needed for them to be elevated. If you look at the docs for the CustomAction table:

http://msdn.microsoft.com/en-us/library/aa368069(v=vs.85).aspx

VS generates ones that have the msidbCustomActionTypeNoImpersonate bit set. Other tools let you say if you want impersonation (of the installing user) or not, but VS does not, so you'd need to use an MSI editor like Orca to edit the CustomAction table after you've identified the right custom action. However it won't run elevated. Longer term, if you need that degree of control, over setups you should look for another setup building tool.

Upvotes: 2

Jim V.
Jim V.

Reputation: 2177

You want to use trusted authentication. This connection string will allow for a silent login to a SQL Server:

Provider=SQLNCLI10;Server=[ServerName OR ServerName\InstanceName];
Database=myDataBase;Trusted_Connection=yes;

Upvotes: 1

Related Questions