Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Specific IIS 7 Site with AppCmd?

I have an IIS 7 machine with multiple apps/vdirs on the single default web site. I would like to set two of them with this authentication: anonymous - off impersonation - on forms auth - off windows auth - on

I would like to do this with appcmd.exe but cannot seem to get the syntax down right. Has anyone had luck with this?

Thanks.

like image 286
Snowy Avatar asked Jul 21 '10 01:07

Snowy


2 Answers

You should try Configuration Editor (included in IIS 7.5 and available for download for IIS 7.0 at http://www.iis.net/download/AdministrationPack), it can generate the AppCmd.exe commands automatically as well as javascript and managed code. Using it I generated the following (for default web site):

appcmd.exe set config "Default Web Site" -section:system.webServer/security/authentication/anonymousAuthentication /enabled:"False"  

appcmd.exe set config "Default Web Site" -section:system.web/identity /impersonate:"True"  

appcmd.exe set config "Default Web Site" -section:system.webServer/security/authentication/windowsAuthentication /enabled:"True"  /commit:apphost

Note that the ones with commit:apphost are because the sections are locked by default which means they need to be set inside ApplicationHost.config using location paths.

like image 51
Carlos Aguilar Mares Avatar answered Oct 20 '22 19:10

Carlos Aguilar Mares


unlock first:

appcmd unlock config /section:windowsAuthentication

refer to: How to set authentication with appcmd.exe or ServerManager

like image 27
Thanga Avatar answered Oct 20 '22 21:10

Thanga