Welcome to MSDN Blogs Sign in | Join | Help

Finding Out The Current User in the Debugger

Every once in a while, while debugging multi-threaded applications that do impersonation, it becomes useful to figure out the context that the current thread is running under.  This is especially useful when debugging server scenarios where connections are farmed out to worker threads which begin their work by impersonating the user logging in.  Before Whidbey finding this information wasn't very straightforward, and even when you found out the current user, it was difficult to find out any other security token information.

Thankfully the VS Whidbey debugger team has stepped up with a nice solution to this problem.  You can now evaluate the $user pseudo-register in the debugger, and find out all about the context that the current process and thread are running under.  In addition to the user name, this variable also shows their SID, session id, login id, impersonation level, and active privileges.  In addition to this, information on all the groups that the active user is a member of is listed.

If the current thread is impersonating, then information on the user the thread is impersonating as is also available.  Here's what this might look like on a thread that is not impersonating:

Evaluating the $user pseudo-register in the VS Whidbey QuickWatch window

Published Thursday, September 23, 2004 6:02 PM by shawnfa

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Finding Out The Current User in the Debugger

Friday, September 24, 2004 1:07 AM by Valery Pryamikov
Wahoo! That’s cool. Kudos to Whidbey team :-).

# Debugging User Security Context

Sunday, December 12, 2004 7:08 AM by Saravana's Blog
Debugging User Security Context

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker