Using appcmd to set the anonymous authentication user for a specific Site

1.7k views Asked by At

If I go through the IIS UI, I can select a Site, open Authentication under IIS, and edit Anonymous Authentication to use the Application pool identity. However, I run into an issue when trying to do the same thing using appcmd:

appcmd set config "SiteName" /section:anonymousAuthentication /userName:

When I run this, I get the following:

ERROR ( message:Can not set attribute "userName" to value "".. Reason: This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
. )

Now, I can obviously do this through the UI, so my appcmd command must be trying to do something different than I am accomplishing through the UI. The question is, how do I replicate my UI actions with appcmd?

1

There are 1 answers

0
Dave Smith On

I just encountered the same issue. As it states, the section you are trying to update is locked so simply run this command prior to yours in order to unlock the anonymous authentication config section:

appcmd unlock config -section:system.webServer/security/authentication/anonymousAuthentication -commitpath:apphost

Your config change should now process successfully!