Built-in helper to parse User.Identity.Name into Domain\Username

后端 未结 8 702
面向向阳花
面向向阳花 2020-12-02 22:23

Is there any built-in utility or helper to parse HttpContext.Current.User.Identity.Name, e.g. domain\\user to get separately domain name if exists

8条回答
  •  孤城傲影
    2020-12-02 22:55

    Although not a .NET built-in, one can always P/Invoke to CredUIParseUserName. Here's a example of how to use it in .NET.

    PS: It doesn't seem to handle the "dot", as in ".\username".

提交回复
热议问题