Solved

WindowsIdentity.GetCurrent().User

Posted on 2008-10-23
6
1,704 Views
Last Modified: 2013-12-17
When I use

WindowsIdentity.GetCurrent().User

a long a number is returned. Is this a static number or does it change everytime I long in.
0
Comment
Question by:Mr_Shaw
  • 3
  • 2
6 Comments
 
LVL 13

Expert Comment

by:TechTiger007
ID: 22787733
I guess this long number is the address of the object returned.
If you need to get the user name use
System.Security.Principal.WindowsIdentity.GetCurrent().Name
0
 
LVL 16

Expert Comment

by:HooKooDooKu
ID: 22788350
.User is returning the SID.  Based on what I can find on Wikipedia, SID is assigned by the Domain controller during the log on process.  So it sounds like it is a value that can change.  I could see it being the same on a relatively static network.  But otherwise, the definision seems to indicated it can change.
http://en.wikipedia.org/wiki/Security_Identifier
0
 

Author Comment

by:Mr_Shaw
ID: 22794451
Is it possible for there to be two users with the same name on a microsoft domain. for example two Mr bloggs?
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 13

Expert Comment

by:TechTiger007
ID: 22794485

there could be two users with same name but they will have different user ids
0
 

Author Comment

by:Mr_Shaw
ID: 22794856
Is this user ID static or can it change every time the user logs on to the network.

How do I return the user ID. I just had a look and intelliesense does not list user ID?
0
 
LVL 13

Accepted Solution

by:
TechTiger007 earned 500 total points
ID: 22795937
User id is the id (username) used by user to login. This will be unique for each user in a network.

System.Security.Principal.WindowsIdentity.GetCurrent().Name
will give you "<domain>\<userid>". You can retrieve the string and split with "\" (backslash) as seperator and you will get the user id.

string domainuserid = System.Security.Principal.WindowsIdentity.GetCurrent().Name
string domainname = "";
string userid = "";
if(domainuserid != null)
{
string[] arr = domainuserid.split('\');
if(arr.Length ==2)
  {
    domainname = arr[0];
    userid = arr[1];
  }
else if(arr.Length == 1)
userid = arr[0];
}

there could be syntax errors. You can start with this
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now