Skip to content

Implement Environment.UserName layoutrenderer #3381

@snakefoot

Description

@snakefoot

Right now one can use these:

Both are extremely slow, and the second one doesn't support impersonations. But there are actually much faster calls:

  • Environment.UserName
  • Environment.UserDomainName

And these should support impersonation, and should also be available of NetCore:

  • On Windows the UserName property wraps a call to the Windows GetUserName function. The domain account credentials for a user are formatted as the user's domain name, the '' character, and user name. Use the UserDomainName property to obtain the user's domain name and the UserName property to obtain the user name.

  • On Unix platforms the UserName property wraps a call to the getpwuid_r function.

  • If an ASP.NET application runs in a development environment, the UserName property returns the name of the current user. In a published ASP.NET application, this property returns the name of the application pool account (such as Default AppPool).

See the output here:

https://richhewlett.com/2011/02/15/getting-a-users-username-in-asp-net/

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions