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
Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

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.