When I deployed my site in IIS7.5, I discovered one strange behavior: when the default application pool identifier remains ApplicationPoolIdentity (as recommended in IIS application pool identifiers ), Ninject seems to be ignored, since I get the following error when creating the very first controller:
System.InvalidOperationException: An error occurred while trying to create a controller of type '..MainController. Make sure that the controller has an immortal public constructor. ---> System.DirectoryServices.DirectoryServicesCOMException: operation failed.
I tried to provide FullAccess to IIS AppPool\<MySiteAppPool> to the folder containing the site (including all subfolders and files), but that didn't change anything.
However, when I set the application pool identifier for any domain account (even a simple one, without administrative privileges, and also without any access to the folder with the site), it works fine.
Ninject is installed in accordance with Configuring the MVC3 application through the NuGet package.
I'm not sure if this matters, the site should be running on a Windows Authenticated Domain Intranet.
So, the only problem seems to be related to the application pool id. As far as I want to use the recommended method, I would like to have ApplicationPoolIdentity , and not a domain account.
What is the reason for this? Is it possible to mix everything together?
Here is an SO thread with a similar problem: ASP.NET MVC 4 + Ninject MVC 3 = There is no constructor without parameters for this object . However, no suitable answer exists.
As a comment made, I tried to use NetworkSerive as an identifier. And it worked correctly. However, I think this is not much better than a non-privileged domain account.
EDIT
Another dependency was unexpectedly discovered: the application pool identifier is used for Windows authentication on the sql server, although I expected that client-side user credentials would be used there.
Based on comments
Agree that a remote sql server can be accessed with authenticated credentials through impersonation.
However, it is still unclear what the problem is with ApplicationPoolIdentity and Ninject.
In the article mentioned at the very top of this question, I suggested that this could be due to the fact that the virtual account does not have a user profile. This aspect remains unclear to me, since you can still enable IIS to load a user profile using the LoadUserProfile attribute. I canβt get what IIS will load if there is no profile for the virtual account?
It says:
IIS does not load the Windows user profile, but some applications may use it anyway to store temporary data. SQL Express is an example application that does this. However, the user profile must be created to store temporary data in the profile or in the registry hive. User profile for Account NETWORKSERVICE was created by the system and was always available. However, with switching to a unique application pool of identifiers, a user profile is not created by the system. Only standard application pools (DefaultAppPool and Classic.NET AppPool) have user profiles on disk. A user profile is not created if the Administrator creates a new application pool.
However, if you want, you can configure IIS application pools to load the user profile by setting the "LoadUserProfile" attribute to "true".
I found the following thread on serverfault.com:
How to assign active directory permissions to the default application pool identifier
It also states that the application pool identifier cannot work as a network service, in particular, request AD.