C # Tips: Get the user who is currently logged on to the computer (local user/domain user)

Source: Internet
Author: User

The namespace of the using is required:

Using System.Security.Principal;

To obtain the user to log on to the computer:

WindowsIdentity WindowsIdentity = WindowsIdentity.GetCurrent (); SecurityIdentifier sid = Windowsidentity.user;

Windowsidentity.name is the username of the user who landed the computer.
The resulting windowsidentity.name assumption is that the workgroup (Workgroup) is logged in. is the computer name \username; Assume that you are logged on to the domain. is the domain name \username.
I'm thinking of the question: if someone has the advantage of setting the computer name to the same name as the domain, is it possible to cheat some applications and forge them into a domain.

So just use it.

Windowsidentity.name to infer whether to log on to the domain. is definitely not enough.

C # Tips: Get the user who is currently logged on to the computer (local user/domain user)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.