Solved

Setting IIS authentication method

Posted on 2008-10-02
6
307 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
ID: 22626775
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
ID: 22633168
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
ID: 22633771
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

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

Author Comment

by:Optibase1
ID: 22658826
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
ID: 22742950
I hope that isn't too late !

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

 


0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

821 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