Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

In deploying a new version of our ASP.NET application, we need to set the authentication method for a particular page to be "Integrated only." We can do this from the IIS managment console, but would like to write a script (batch or powershell, doesn't matter) that will make the change to ensure that everything goes smoothly in the deployment.

The rest of the pages in the application will allow different authentication methods, but this particular page will only allow integrated.

In the same deployment, we also need to change the location of the custom error pages for all 401 errors, preferably also from the command line.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

AdsUtil.VBS is your friend:

adsutil.vbs set  W3SVC/1/root/AuthNTLM true
adsutil.vbs set  W3SVC/1/root/AuthAnonymous false
adsutil.vbs set  W3SVC/1/root/AuthBasic  false
adsutil.vbs set  W3SVC/1/root/AuthPassport false
adsutil.vbs set  W3SVC/1/root/AuthMD5 false

Which is the same as:

adsutil.vbs set  W3SVC/1/root/AuthFlags 5

Note that <1> is your web site ID.

For CustomErrors, you need to update the root/HTTPErrors field which is actually a LIST item. David Wang has the appropriate script for this: chglist.vbs

chglist.vbs W3SVC/1/HttpErrors 404 404,*,URL,/CustomErrors/404.asp /COMMIT

For individual files, you can add them after the /Root/ Path:

adsutil.vbs set W3SVC/1/root/MyFile.txt/AuthFlags 5
share|improve this answer
    
Is it possible to set the authentication on one particular page rather than the whole web site? –  Brien May 29 '09 at 17:36

You can control authentication from a web.config file. You would put the following in your web.config (from http://msdn.microsoft.com/en-us/library/aa291347(VS.71).aspx):

<system.web>
   <!-- mode=[Windows|Forms|Passport|None] -->
   <authentication mode="Windows" />
</system.web>

Alternatively, you could check out the System.DirectoryServices API for IIS 5 & 6 (http://msdn.microsoft.com/en-us/library/system.directoryservices.aspx) or the Microsoft.Web.Administration API for IIS 7 (http://msdn.microsoft.com/en-us/library/microsoft.web.administration.aspx).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.