Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding SQL permissions for just created application pool identity in WiX

Tags:

sql

iis

wix

I have a WiX package that has one component creating an IIS 7 application pool which has the ApplicationPoolIdentity identity (IIS AppPool\AppPoolName). I then have another component to add permissions in a SQL Server database for this identity (I am using the SqlString extension).

When the SQL runs to add permissions I get the following error:

Windows NT user or group 'IIS AppPool\AppPoolName' not found.

I'm assuming this is happening because the IIS stuff is happening in a transaction and the application pool has not actually been committed quite yet.

Does anyone have a better approach to this problem?

Thanks!

like image 986
toddkitta Avatar asked Mar 04 '11 22:03

toddkitta


2 Answers

As far as I understand the way WiX IIS extension works, it creates a metabase backup before applying any changes. Then, in deferred sequence, it does all actions you instructed it to do. If an error occurs, rollback action just restores the previous state from backup. Otherwise, if everything is ok, commit actions just drops the backup snapshot.

So, taking this into account, I don't think your guess it correct. It should be possible to do what you want. I suspect the problem is in action sequencing. Make sure IIS actions go first, then SQL stuff, and permissions go last. In such a way the first thing you create an AppPool, then do SQL stuff, and finally apply required permissions. Well, I might be wrong, but you should find the right sequence by try-and-error approach.

And the rule of thumb: always generate a verbose log. It contains everything. Seriously, that's the best thing I like about Windows Installer: whatever has happened, you'll find it in verbose log. Good luck!

like image 118
Yan Sklyarenko Avatar answered Nov 15 '22 09:11

Yan Sklyarenko


Why not create a custom action that configures IIS for you? You could use a simple custom action that just executes a set of appcmd commands OR create a managed (C#) custom action that programatically uses the Microsoft.Web.Administration.ServerManager to configure IIS7.

like image 40
Elmar de Koning Avatar answered Nov 15 '22 08:11

Elmar de Koning