Fix: CurrentUserId returned domain

This commit is contained in:
Gary Sharp
2013-10-14 16:23:59 +11:00
parent 4d19e381fd
commit 24751780cc
+12 -3
View File
@@ -37,17 +37,26 @@ namespace Disco.Services.Users
{ {
get get
{ {
string userId;
// Check for ASP.NET // Check for ASP.NET
if (HttpContext.Current != null) if (HttpContext.Current != null)
{ {
if (HttpContext.Current.Request.IsAuthenticated) if (HttpContext.Current.Request.IsAuthenticated)
return HttpContext.Current.User.Identity.Name; userId = HttpContext.Current.User.Identity.Name;
else else
return null; return null;
} }
else
{
// User default User
userId = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
}
// User default User if (userId.Contains("\\"))
return System.Security.Principal.WindowsIdentity.GetCurrent().Name; return userId.Substring(checked(userId.IndexOf("\\") + 1));
else
return userId;
} }
} }