[英]How do I programmatically set Integrated Windows Authentication in IIS on a .NET web service?
I have a web service project that needs to be set to use Integrated Windows Authentication after installation. 我有一个Web服务项目需要设置为在安装后使用集成Windows身份验证。 Normally, I would install the web service, then manually go to IIS and make sure the box is checked for Integrated Windows Authentication.
通常,我会安装Web服务,然后手动转到IIS并确保选中“集成Windows身份验证”框。 There has to be a way to do this through code.
必须有一种方法可以通过代码执行此操作。 I have looked up on using the Installer class.
我已经查看了使用Installer类。 It looks like this is something I could use, but I have not found anything on setting properties programmatically in IIS.
看起来这是我可以使用的东西,但我没有在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();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.