2013-08-27 141 views
1

我有一個Intranet網站,我開發了我想使用Windows身份驗證。IIS Windows身份驗證IIS APPOOL

在我的代碼中,我使用以下命令獲取登錄用戶的用戶名以顯示在頁面的頂部。

string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name; 
     ThisLoginName.Text = userName.ToString(); 

然而,在用戶名頂部什麼呢顯示器「IIS APPPOOL \ WebsiteName」我已經改變了IIS 7.0身份驗證只有Windows驗證。

我在做什麼錯?

感謝

+0

你在冒充嗎? – wes

+0

如果我將它設置爲true,它會給我一個錯誤 – SteveU

+0

去檢查[this](http://forums.asp.net/t/1507047.aspx?WindowsIdentity%20GetCurrent%20Name %20vs%20User%20Identity%20Name)鏈接,它會給你在IIS級別的認證概述。 – Kulkarni

回答

2

您應該使用:HttpContext.Current.User.Identity.Name獲得認證的用戶名。您的代碼會返回在服務器上運行Web進程的用戶的用戶名。

+0

嗯,仍是同樣的問題。 – SteveU