Sunday, May 1, 2011

Confuserion - a quiz

It can be a little tricky to work out who you are when you’re some running code (‘behind’) in ASP.NET.

Assuming my machine is called MYMACHINE, my domain is MYDOMAIN, my username is rik and I’m logged in as MYDOMAIN/rik, what will the following return?
  1. Environment.UserDomainName & "\\" & Environment.UserName
  2. System.Security.Principal.WindowsIdentity.GetCurrent().Name()
  3. HttpContext.Current.User.Identity.Name
  4. Threading.Thread.CurrentPrincipal.Identity.Name

Bonus point: Whose registry setting will this affect?

Registry.CurrentUser.OpenSubKey
(
  @"Software\Microsoft\Internet Explorer\PageSetup",
  true
).SetValue("footer", "xxx")

No comments:

Post a Comment