gpt4 book ai didi

.net - 将 IIS 网站应用程序设置为使用应用程序池身份进行匿名身份验证(通过代码)

转载 作者:行者123 更新时间:2023-12-02 08:19:32 24 4
gpt4 key购买 nike

I can see here如何启用匿名身份验证并专门为凭据设置用户名和密码。谁能告诉我是否可以使用 .NET 设置凭据以使用应用程序池的身份?我看不到以编程方式执行此操作的方法。

enter image description here

    Public Sub CreateApplication(ByVal website As String, ByVal application As String, ByVal path As String, applicationPoolName As String)

Using manager As New ServerManager()
manager.Sites(website).Applications.Add("/" & application, path)
manager.CommitChanges()
manager.Sites(website).Applications("/" & application).ApplicationPoolName = applicationPoolName

Dim config As Configuration = manager.GetApplicationHostConfiguration
Dim anonymousAuthenticationSection As ConfigurationSection = config.GetSection("system.webServer/security/authentication/anonymousAuthentication", website & "/" & application)
anonymousAuthenticationSection("enabled") = True
manager.CommitChanges()
End Using

End Sub

最佳答案

迟到的回复(希望它会对某人有所帮助)您可以将其设置为使用应用程序池身份,只需将配置的该部分的用户名和密码设置为空白即可,例如

(请原谅 C# 语法)

        var config = _IIS.GetApplicationHostConfiguration();
var anonymousAuthenticationSection = config.GetSection( "system.webServer/security/authentication/anonymousAuthentication", name );
anonymousAuthenticationSection[ "enabled" ] = true;
//use app pool user
anonymousAuthenticationSection[ "userName" ] = "";
anonymousAuthenticationSection[ "password" ] = "";

关于.net - 将 IIS 网站应用程序设置为使用应用程序池身份进行匿名身份验证(通过代码),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16964440/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com