[英]Integrated Windows Authentication not working for MVC .NET web app on IIS
[英]How do I programmatically set Integrated Windows Authentication in IIS on a .NET web service?
我有一個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();
看看WebDeploy 。 這項技術由MS設計,用於部署Web應用程序。 ;-)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.