asp.net-core-2.0 - 如何在 IIS 中获取 Windows 登录用户名定义匿名 + Windows 身份验证
问题描述
框架:ASP.NET CORE 2.2 作为 web-api 服务器:IIS-10 (Windows server 2016)
我需要同时使用WindowsAuthentication和AnonymousAuthentication。我有这两个选项以某种方式获取Windows LoggedIn User:
User.Identity.Name;
System.Security.Principal.WindowsIdentity.GetCurrent().Name
我在一个匿名的端点(控制器方法)中使用它们。
IISExpress 一切正常,但是在使用 IIS(本地或部署后)时,我无法得到想要的结果:
User.Identity.Name; // return null
System.Security.Principal.WindowsIdentity.GetCurrent().Name //return IISAPPPOOL\<Application pool name>
应用程序池标识是 ApplicationPoolIdentity。
如何在此配置中获取Windows LoggedIn 用户名(匿名 + Windows 身份验证)?
解决方案
推荐阅读
- syntax - 预测期开始于定义之前
- oracle - Oracle 数据集成器中的错误 ORA-12154
- python - 从另一个 DataFrame 添加多个列时 Pandas KeyError
- java - 如何解析 lambda 函数作为输入接收到的未转义 json?
- sql - 在 SQL 中计算一列中的不同行
- r - 逐步left_join/merge
- c - 值和函数指针的联合
- java - 如何通过 API 注册亚马逊 MWS
- hyperledger-fabric - 交易调用上的 Hyperledger Fabric 1.4 错误
- c++ - 是否可以在 C++ 派生类的特定偏移处附加结构?