Created
February 25, 2019 06:08
-
-
Save blubbll/46b0bf837cc5d68f6ff2c9ae73ee85e3 to your computer and use it in GitHub Desktop.
c# identity fun
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
res.Write(System.Environment.MachineName); | |
res.Write(new DirectoryInfo(@"C:\\Users").GetDirectories() | |
.OrderByDescending(d => d.LastWriteTimeUtc).First()); | |
WindowsPrincipal windowsPrincipal = (WindowsPrincipal)Thread.CurrentPrincipal; | |
res.Write("username principal" + windowsPrincipal.Identity.Name); | |
res..ServerVariables["LOGON_USER"] | |
res.Write(System.Web.HttpContext.Current.User.Identity.Name); | |
if (context.Session["user"] != null) | |
{ | |
var user = getUser(context.Session["user"].ToString()); | |
if (user != null) | |
res.Write(JsonConvert.SerializeObject(new | |
{ | |
user = user.samaccountname, | |
name = user.displayname | |
})); | |
} | |
//Falls debug (z.B. lokaler IIS) | |
else if(HttpContext.Current.Request.Url.Host == "localhost") | |
{ | |
//lokalen Nutzer herausfinden | |
var user = getUser(new DirectoryInfo(@"C:\\Users").GetDirectories() | |
.OrderByDescending(d => d.LastWriteTimeUtc).First().ToString()); | |
if (user != null) | |
res.Write(JsonConvert.SerializeObject(new | |
{ | |
user = user.samaccountname, | |
name = user.displayname | |
})); | |
} | |
else res.Write(JsonConvert.SerializeObject(new | |
{ | |
user = "null", | |
name = "null" | |
})); | |
res.Write(System.Environment.MachineName); | |
res.Write(new DirectoryInfo(@"C:\\Users").GetDirectories() | |
.OrderByDescending(d => d.LastWriteTimeUtc).First()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment