简体   繁体   English

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

[英]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();

Take a look at WebDeploy . 看看WebDeploy This technology is designed by MS to, umm, deploy web apps. 这项技术由MS设计,用于部署Web应用程序。 ;-) ;-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 集成Windows身份验证不适用于IIS上的MVC .NET Web应用 - Integrated Windows Authentication not working for MVC .NET web app on IIS 如何在安装时在.NET Web服务上设置基本身份验证? - How do I set basic authentication on .NET web service on install? 如何以编程方式设置Windows服务的权限? - How do I programmatically set a permission to a windows service? Asp.net WCF和集成的Windows身份验证和IIS 6.0 - Asp.net WCF and integrated Windows authentication and IIS 6.0 使用“ Windows身份验证”将Windows服务验证为iis Web服务 - Authenticate a Windows Service to a iis web service with “Windows Authentication” IIS 7.5 Windows集成身份验证混乱 - IIS 7.5 Windows integrated authentication confusion 如何为一些但不是所有集线器在 SignalR 中设置集成 Windows 身份验证 - How to set Integrated Windows Authentication in SignalR for some but not all hubs 如何以编程方式将信息发送到C#with .NET中的Web服务? - How do I programmatically send information to a web service in C# with .NET? 如何创建用于身份验证的 Windows 服务,自定义 Web 应用程序可使用该服务对 AD 用户进行身份验证? - How do I create a windows service for authentication that custom web applications can use to authenticate AD users? 如何在 .NET 中以编程方式重新启动 Windows 服务 - How can I restart a windows service programmatically in .NET
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM