Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8789991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:32:31+00:00 2026-06-13T22:32:31+00:00

Can someone provide a code sample or resource which can help me programatically get

  • 0

Can someone provide a code sample or resource which can help me programatically get status, enable and disable extended protection for authentication in IIS 7/IIS 7.5 using C#?

C# with WMI/ADSI is preferred.

i.e I am asked to use System.Management API or Microsoft.Web.Administration API using C# and i need to determine if EAP is enabled or not on a web server level (as web server default for all future websites).

Any other solution using C# is also welcome.

Looking forward to helpful answers. Thanks

Steve

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:32:32+00:00Added an answer on June 13, 2026 at 10:32 pm

    Microsoft graciously provided a web page that not only explains this new concept (i.e., Extended Protection for Authentication, flag=extendedProtection), but provides sample code (copied below) in several languages. Here’s their C# code to enable EAP in IIS7/7.5.

    Implementing this over WMI will need to use explicit credentials and set impersonationLevel=Impersonate. An alternate method was recently created by Frank White on SO, and I detailed a fully fleshed code for it here: https://stackoverflow.com/a/11948096/1569434

    using System;
    using System.Text;
    using Microsoft.Web.Administration;
    
    internal static class Sample
    {
       private static void Main()
       {
          using (ServerManager serverManager = new ServerManager())
          {
             Configuration config = serverManager.GetApplicationHostConfiguration();
    
             ConfigurationSection windowsAuthenticationSection = config.GetSection("system.webServer/security/authentication/windowsAuthentication", "Default Web Site");
             windowsAuthenticationSection["enabled"] = true;
    
             ConfigurationElement extendedProtectionElement = windowsAuthenticationSection.GetChildElement("extendedProtection");
             extendedProtectionElement["tokenChecking"] = @"Allow";
             extendedProtectionElement["flags"] = @"None";
    
             ConfigurationElementCollection extendedProtectionCollection = extendedProtectionElement.GetCollection();
    
             ConfigurationElement spnElement = extendedProtectionCollection.CreateElement("spn");
             spnElement["name"] = @"HTTP/www.contoso.com";
             extendedProtectionCollection.Add(spnElement);
    
             ConfigurationElement spnElement1 = extendedProtectionCollection.CreateElement("spn");
             spnElement1["name"] = @"HTTP/contoso.com";
             extendedProtectionCollection.Add(spnElement1);
    
             serverManager.CommitChanges();
          }
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The AppDomain.TypeResolve is mysterious in my eyes. Can someone provide a sample code that
Hey Guys! Me again! Can someone provide me with some example code of how
Can someone provide basic sample / link for MVP Framework. Need to design a
Can someone provide a working example in which stored procedure returns a recordset and
which library do i need to import to use medianBlur? can someone provide a
A simple question, but could someone provide sample code as to how would someone
Can someone provide an example of android code to send simple data to PHP
I'm new to this kabeja package so please can some one provide code example
Can someone provide an example of how to load a .svg file and display
Can someone provide a quick top level explanation of how Valgrind works? An example:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.