public static bool UseImpersonation(IIdentity user) { bool rc = true; if (SynapseServer.Config.WebApi.UseImpersonation == false) { rc = false; } else if (SynapseServer.Config.WebApi.Authentication.Scheme == System.Net.AuthenticationSchemes.Anonymous) { rc = false; } else { string currentUser = user?.Name; string runningAsUser = Impersonator.WhoAmI()?.Name; if (currentUser == null) { rc = false; } else if (currentUser.ToLower() == runningAsUser.ToLower()) { rc = false; } } return(rc); }