Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the users network login name?

I'm building a C# application, and I want to identify users by their username. For example, if I logged onto the domain mydomain as the user myusername I'd want to get the mydomain\myusername so I can identify the user.

How can I do this with C#?

like image 664
Malfist Avatar asked May 29 '09 16:05

Malfist


People also ask

How do I find my network login credentials?

Go to Control Panel > User accounts. From there, navigate to Credential Manager > Windows Credentials. You will see a field Add Windows Credentials, tap on it. In this menu, you can add the computer's name you want to access, username and password.

What is a network login name?

A Username is a special name given to a person to uniquely identify them on a computer network. Also called account names, login IDs, or user IDs, usernames are given to a person by the network administrator or they are selected by the user.

How do I find the user name and password for my computer?

Click on the Control Panel. Go to User Accounts. Click on Manage your network passwords on the left. You should find your credentials here!


1 Answers

It's very simple indeed:

Environment.UserName

From the MSDN page:

The UserName property provides part of the credentials associated with computer domain names, as returned by the UserDomainName property. This information is typically represented as DOMAIN\username.

This property can be used to identify the current user to the system and application for security or access purposes. It can also be used to customize a particular application for each user.

You can also get the domain name using Environment.UserDomainName.

like image 169
Noldorin Avatar answered Oct 26 '22 13:10

Noldorin