【问题标题】:Querying the current user's identity using WindowsIdentity?使用 WindowsIdentity 查询当前用户的身份?
【发布时间】:2012-07-04 15:19:28
【问题描述】:

我正在使用 WindowsIdentity 获取当前用户的 ID 以执行 SSO。在大多数情况下,我得到的正是我想要的,但对于某些用户来说,我得到了奇怪的结果。示例代码:

IIdentity WinId = HttpContext.Current.User.Identity;
WindowsIdentity wi = (WindowsIdentity)WinId;
String idName = wi.Name.Replace(@"TESTHQ\", "");

有时我会收到duy@test.org,然后我就可以登录了。其他时候我会收到 jone@test.org/broadcast@test.org。

有没有可以让我使用 Windows 7 查看当前身份的地方?比如在控制面板里什么的?

谢谢!

【问题讨论】:

    标签: c# single-sign-on wif


    【解决方案1】:

    然后您可以更改代码以拆分 / 上的值

    试试

    WindowsIdentity MyIdentity = WindowsIdentity.GetCurrent();
    

    【讨论】:

    • 我不明白为什么它会得到“jone@test.org/broadcast@test.org” 有没有办法可以看到它从哪里获取这些信息? WindowsIdentity.GetCurrent 会做什么?
    猜你喜欢
    • 1970-01-01
    • 2021-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-23
    • 2019-10-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多