I want to get current user in high-trust apps at sharepoint 2013 on-premises environment. But each returned user are the same, how can i get the correct current user? Here is my code:
public ActionResult Index()
{
TokenHelper.TrustAllCertificates();
var sharepointUrl = Request.QueryString["SPHostUrl"];
var clientContext = TokenHelper.GetS2SClientContextWithWindowsIdentity(new Uri(
sharepointUrl), Request.LogonUserIdentity);
clientContext.Load(clientContext.Web.CurrentUser, user => user.LoginName);
clientContext.Load(clientContext.Web);
clientContext.ExecuteQuery();
string result = "<h2>Web title retrieved using the managed client object model</h2>";
result += "<p>" + clientContext.Web.Title + "</p>";
clientContext.Dispose();
ViewBag.Content = result;
ViewBag.User = string.Format("Current UserName:{0}", clientContext.Web.CurrentUser.LoginName);
return View();
}