Saar Carmi

A .NET Blog

<November 2008>
SuMoTuWeThFrSa
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456


Navigation

Subscriptions

Post Categories



Monday, November 29, 2004 - Posts

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();

}

posted Monday, November 29, 2004 2:32 AM by saarc with 6 Comments




Powered by Dot Net Junkies, by Telligent Systems