Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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()
        var sharepointUrl = Request.QueryString["SPHostUrl"];

        var clientContext = TokenHelper.GetS2SClientContextWithWindowsIdentity(new Uri(
            sharepointUrl), Request.LogonUserIdentity);

        clientContext.Load(clientContext.Web.CurrentUser, user => user.LoginName);


        string result = "<h2>Web title retrieved using the managed client object model</h2>";
        result += "<p>" + clientContext.Web.Title + "</p>";


        ViewBag.Content = result;
        ViewBag.User = string.Format("Current UserName:{0}", clientContext.Web.CurrentUser.LoginName);

        return View();
share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.