我有以下代码: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