Solved

Setting IIS authentication method

Posted on 2008-10-02
6
269 Views
Last Modified: 2008-11-23
Hi,
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
0
Comment
Question by:Optibase1
  • 3
  • 3
6 Comments
 
LVL 8

Expert Comment

by:paololabe
Comment Utility
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.

Paolo.
0
 

Author Comment

by:Optibase1
Comment Utility
Thanks,
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
0
 
LVL 8

Expert Comment

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


ToggleAutentication(AnonymousCheckBox.Checked)

Read also this reference http://msdn.microsoft.com/en-us/library/ms525389.aspx 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()
 

    try

    {

        Process exeProcess = Process.Start(startInfo);

        exeProcess.WaitForExit();

        exeProcess.Close();

    }

    catch

    {

        // manage exception

        return;

    }

}

Open in new window

0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:Optibase1
Comment Utility
Thanks,
I'll try it soon and let you know
0
 

Author Comment

by:Optibase1
Comment Utility
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...
thanks
0
 
LVL 8

Accepted Solution

by:
paololabe earned 500 total points
Comment Utility
I hope that isn't too late !

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

 


0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Running classic asp applications under Windows Server 2008 R2 (x64) and IIS 7 is not as easy as one may think. It took me a while to figure it out while getting error 8002801d a few times. After you install the OS you will need to install the fol…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now