I would like to be able to detect, from ASP.NET code, whether IIS currently has "Windows Authentication" "available"?
Starting from my application installed and currently running under "Anonymous Access", I want to detect:
- "Windows Authentication" component has actually been installed in IIS (e.g. some IIS7 have it not installed by default); and...
- "Windows Authentication" is actually "Enabled" on my virtual root/location.
I want this information to let the Administrator know whether he needs to take action in IIS before he actually attempts to switch it on on my application.
(Hence, for example, I think IIS7: How to define that windows authentication is turned on? does not help me, as that is looking at whether it is already on for my application; I want to know whether it is installed/can be turned on.)
My "solution" would need to work (or at least not "fail") with versions of IIS prior to 7 as well as 7 itself, so if there are differences there I need to know. Thanks.
applicationHost.config
file can also be used to determine whether windows authentication is installed. All you have to do is query the globalModules section for a module with the name "WindowsAuthenticationModule" (it's rather easy). Unfortunately, I had to elevate the application pool identity's permission to query the applicationHost.config file ...