Setting IIS authentication method

I would like to controll IIS authentication method from code or config file.
I need to control the "Integrated windows authentication" to be "Checked" or not. I must do it from the code or config file. (of course it is not mandotory to be "checked at the IIS directory security GUI)
When it is not checked I have to allow "Anonymous" access.
All the configuration must be done from a web page that runs under the same configured IIS.
If I need a special authorization please let me know.
Thanks Ranny
Who is Participating?
paololabeConnect With a Mentor Commented:
I hope that isn't too late !

You could use:
startInfo.RedirectStandardOutput = true
and read the stream startInfo.StandardOutput


You could use the adsutil.vbs script
Calli the script throuth the System.Diagnostics.Process class.

the command should be:
cscript adsutil.vbs set [apppath]/authntlm [false|true]

replace st with get to know the current status

Another way could be WMI library.

You should run the aspx pagewith admin permission.

Optibase1Author Commented:
where should I make the call or use the vbs file?
Sorry, I'm only familiar with C# or javascript.
If you could make an example I'll be :-)
Thanks again
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

You could create a method in the page (for example ToggleAutentication) and call it when you set the checkbox or postback the page


Read also this reference explaining hot to use ADSI to explore IIS metabase using c#

using System.Diagnastics;
private void ToggleAutentication(IsAnonymous bool)
    ProcessStartInfo startInfo = new ProcessStartInfo();
    startInfo.CreateNoWindow = false;
    startInfo.UseShellExecute = false;
    startInfo.FileName = "cscript";
    startInfo.WindowStyle = ProcessWindowStyle.Hidden;
    startInfo.Arguments = "adsutil.vbs set [apppath]/authntlm " + IsAnonymous.ToSTring().ToLower()
        Process exeProcess = Process.Start(startInfo);
        // manage exception

Open in new window

Optibase1Author Commented:
I'll try it soon and let you know
Optibase1Author Commented:
Hi paololabe,
I cannot really make it work.
If I use the "get" option, where should I expect to see the answer ?
Does any other parameter than "IsAnonymous" should be fill by me?
sorry for bothering...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.