Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

C# Active Directory Get current user logged into Windows

Posted on 2004-03-22
2
Medium Priority
?
1,334 Views
Last Modified: 2007-12-19
Hello Expert, I was wondering if you could help me with code that will Get the current user logged into Windows Active Directory I am using a C# Windows Form. I just need to get the user name of who is on the pc at this time.
Thanks
0
Comment
Question by:jvoros1
  • 2
2 Comments
 
LVL 12

Expert Comment

by:esteban_felipe
ID: 10655552
Hi jvoros1,

WindowsPrincipal wp = new WindowsPrincipal(WindowsIdentity.GetCurrent());
String username = wp.Identity.Name;


Esteban Felipe
www.estebanf.com
0
 
LVL 12

Accepted Solution

by:
esteban_felipe earned 2000 total points
ID: 10655559
jvoros1,

you need to add System.Security.Principal namespace to your code

using System.Security.Principal;

Esteban Felipe
www.estebanf.com
0

Featured Post

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question