弘帝企业智能建站系统交流平台

 找回密码
 立即注册
查看: 905|回复: 0

【IIS】匿名身份验证 <anonymousAuthentication>

[复制链接]
发表于 2024-3-5 20:38:43 | 显示全部楼层 |阅读模式
摘自:https://learn.microsoft.com/zh-c ... ymousauthentication

using System;
using System.Text;
using Microsoft.Web.Administration;

internal static class Sample {
   private static void Main() {
      using (ServerManager serverManager = new ServerManager()) {
         Configuration config = serverManager.GetApplicationHostConfiguration();
         ConfigurationSection anonymousAuthenticationSection = config.GetSection("system.webServer/security/authentication/anonymousAuthentication", "Contoso");
         anonymousAuthenticationSection["enabled"] = true;
         anonymousAuthenticationSection["userName"] = @"IUSR";
         anonymousAuthenticationSection["password"] = @"P@ssw0rd";
         serverManager.CommitChanges();
      }
   }
}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|弘帝企业智能建站系统 ( 皖ICP备07503252号 )

GMT+8, 2024-11-23 23:51 , Processed in 0.081610 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表