c# - 如何以编程方式在 .NET Web 服务的 IIS 中设置集成 Windows 身份验证?

标签 c# windows authentication iis-6 integrated

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

最佳答案

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();

关于c# - 如何以编程方式在 .NET Web 服务的 IIS 中设置集成 Windows 身份验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2661425/

相关文章:

java - Android——如何以编程方式从表单登录网站

C# 使用数组编码(marshal)结构

c# - R# : Stop it touching ghostdoc XML comments on Code Cleanup?

Windows 包含 PHP?

java - 获取不到主板序列号

authentication - 需要帮助修复此错误 "Connection reset by peer - SSL_connect"

iphone - 我可以使用 facebook-connect 作为我的用户身份验证吗?

c# - 当您还需要 "default"具体依赖项时,哪种依赖项注入(inject)更好的模式?

c# - 为什么 ASP.NET/Visual Studio Web 开发服务器这么慢?

windows - 如何在 Windows 8 中安装、编译和使用 Rebar