Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Tokens and Security Context

Tip of the day, when logging information for diagnosing a problem, or simply logging an error  (log file, event viewer, etc) make sure you are logging the program's security context as far as the operating system system is concerned (Keith Brown: The .Net Developers Guide to Windows Security).

You will then know "Who am I?" We are  doing this in our app and it has helped it some cases.  Perhaps the user is being denied access to a secured resource and you do not know why. Know the WindowsIdentity.GetCurrent will help you figure out why. 

Simply add this call:

Dim id as string = WindowsIdentity.GetCurrent()

the log this:

id.Name

for your User Name

BTW, the Application Exception Block does this for you (the default).

 

 

1 Comment

Comments have been disabled for this content.