Wednesday, 29 May 2019

C# Get Logged-in User in IIS and IISExpress

public string LoggedInUserNetworkId() { string loggedinUser = WindowsIdentity.GetCurrent().Name; // IIS Express loggedinUser = !string.IsNullOrEmpty(loggedinUser) && !loggedinUser.ToLower().Contains("apppool") ? loggedinUser : HttpContext.Current.User.Identity.Name; // IIS return (!string.IsNullOrEmpty("Impersonate".GetValueFromConfig()) ? "Impersonate".GetValueFromConfig() : loggedinUser.Replace("DOMAIN\\", "")).PrettyWord(); } public static string PrettyWord(this string word) => System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo .ToTitleCase(word.Trim().ToLower());

No comments:

Analysis Service in Power BI Report Server

 We couldn’t connect to the Analysis Services server. Make sure you’ve entered the connection string correctly... link