【发布时间】:2011-06-08 10:57:43
【问题描述】:
我在一个 aspx 页面中有以下代码:
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>
当以管理员 Bob 身份登录时,我得到以下输出
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吗?您是在本地运行网站吗?
-
除非您使用模拟,否则您不会获取浏览用户的任何凭据...
标签: asp.net windows-authentication