【问题标题】:How do I programmatically set Integrated Windows Authentication in IIS on a .NET web service?如何以编程方式在 .NET Web 服务上的 IIS 中设置集成 Windows 身份验证?
【发布时间】:2011-02-09 07:47:55
【问题描述】:

我有一个 Web 服务项目,需要在安装后设置为使用集成 Windows 身份验证。通常,我会安装 Web 服务,然后手动转到 IIS 并确保选中了集成 Windows 身份验证框。必须有一种方法可以通过代码来做到这一点。我一直在使用 Installer 类。看起来这是我可以使用的东西,但我没有找到任何关于在 IIS 中以编程方式设置属性的内容。

【问题讨论】:

    标签: c# windows authentication iis-6 integrated


    【解决方案1】:

    看看WebDeploy。这项技术是由 MS 设计的,用于部署 Web 应用程序。 ;-)

    【讨论】:

      【解决方案2】:
      String applicationPath = String.Format("{0}/{1}", _server.Sites["Default Web Site"].Name, "AppName");
      
      Configuration config = _server.GetApplicationHostConfiguration();
      
      ConfigurationSection anonymousAuthenticationSection = config.GetSection("system.webServer/security/authentication/anonymousAuthentication", applicationPath);
      
      anonymousAuthenticationSection["enabled"] = false;
      
      ConfigurationSection windowsAuthenticationSection = config.GetSection("system.webServer/security/authentication/windowsAuthentication", applicationPath);
      
      windowsAuthenticationSection["enabled"] = true;
      
      _server.CommitChanges();
      

      【讨论】:

      • 我收到“无法在此处访问受保护的内部索引器 'this'”消息
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-18
      相关资源
      最近更新 更多