我有以下代碼:ASP.NET驗證問題
protected void Page_Load(object sender, EventArgs e)
{
if (User.Identity.IsAuthenticated)
lblAuthentication.Text =
"Authenticated user: " + User.Identity.Name;
else
lblAuthentication.Text =
"User not authenticated. Anonymous access ";
lblWindowsIdentity.Text =
"Windows identity: " + WindowsIdentity.GetCurrent().Name;
} // Page_Load()
web.config設置如下:
<authentication mode="Windows" />
<authorization>
<allow users="*" />
</authorization>
當鮑勃登錄誰是管理員我獲得以下輸出
Authenticated user: Bob-PC\Bob
Windows identity: Bob-PC\Bob
附加代碼顯示了我:
Administrator: True
User: True
Guest: False
PowerUser: False
AccountOperator: False
SystemOperator: False
然後我切換用戶(Windows Vista),以訪客身份登錄,瀏覽到同一網站,我得到相同的輸出?
Authenticated user: Bob-PC\Bob
Windows identity: Bob-PC\Bob
Administrator: True
User: True
Guest: False
PowerUser: False
AccountOperator: False
SystemOperator: False
爲什麼我爲不同的用戶獲得相同的輸出?
確保沒有緩存。你使用IE嗎?你在本地運行網站嗎? – marto 2011-06-08 11:00:43
除非您使用模擬,否則您將無法獲取瀏覽用戶的任何憑據... – Exitos 2011-06-08 11:03:42