[英]How to get ADAL to check username before using cached login credentials to logon user to application
[英]How get logon username
string userName=System.Security.Principal.WindowsPrincipal(
System.Security.Principal.WindowsIdentity.GetCurrent()).Identity.Name;
在我的本地PC上調試時,我得到了我的Windows用戶名,但是當在服務器上運行時,我得到“NT AUTHORITY \\ NETWORK SERVICE”;
您應該嘗試在配置中將身份驗證模式設置為Windows,並禁用授權標記中的匿名用戶。 ( 來自之前的回答 ):
要將當前登錄的用戶轉換為Windows帳戶,您必須使用Windows authentication
而不是Forms authentication
:
在本地PC的調試中,獲取Windows UserName,但在服務器中獲取“NT AUTHORITY \\ NETWORK SERVICE”;
它顯示了應用程序當前用戶。 在Visual Studio Web服務器上托管應用程序時,它使用您的本地帳戶。 但是,當您使用不同憑據登錄Web應用程序時,它將始終顯示您當前的Windows登錄名。
部署到IIS的應用程序在您的情況下使用NT AUTHORITY \\ SYSTEM帳戶。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.