![](/img/trans.png)
[英]C# Web API with Windows Authentication - Get Local Windows Users Groups with readable group name- No AD
[英]c# .net Web Api Windows and Anonymous Authentication get current user
我試圖獲得本地用戶,但我沒有回報。
我的 IIS 已啟用:
Visual Studio 2017 C# .net 4.6.1
我已經嘗試標記網絡配置:
<authorization>
<allow users="?" />
</authorization>
AND
<identity impersonate="false" />
<authentication mode="Windows" />
代碼 WebApi
[HttpGet]
[Authorize]//I already tried [AllowAnonymous]
public User Get()
{
System.Net.NetworkCredential SystemCredential = (System.Net.NetworkCredential)ADUtil.SystemCredential();
string login = HttpContextUtil.Request.LogonUserIdentity.Name;
error here, login return 'NT AUTHORITY\IUSR'.
}
您不能在應用程序中混合身份驗證模式而不會陷入混亂。 你必須選擇一個並堅持下去。
AllowAnonymous
屬性讓您無需身份驗證即可訪問特定控制器。 它們是否經過身份驗證取決於您的身份驗證方法。 它通常用於訪問登錄頁面,但也可用於不需要限制訪問的站點區域。
可能最簡單的方法是在 IIS 中禁用除“Windows”之外的所有內容
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.