Setting IIS to support Windows Authentication and Content Expiration by code
I was wondering how to set the IIS virtual directory to Windows Authentication during the application install time.
Well, here is the code snip.
Using System.DirectoryServices;
const int MD_AUTH_NT = 0x00000004; //Windows authentication schemes available.
DirectoryEntry folderRoot
= new DirectoryEntry("IIS://localhost/W3SVC/1/Root/" + virutalDirecty);
folderRoot
.RefreshCache();
folderRoot
.Properties["AuthFlags"].Value = MD_AUTH_NT; //Windows authentication
folderRoot
.Properties["HttpExpires"].Value = "D, 86400"; //Content expiration after 1 day
folderRoot
.CommitChanges();
}