You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
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:
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/
The text was updated successfully, but these errors were encountered: