title: How to get Current User in Sharepoint site workflow 2010?
body: <p>Am trying to find the current logged user in sharepoint site workflow 2010 while creating a project. Based on the user, I would like to retrieve the current user's project manager. Every time am trying to retrieve current user name, it's giving <strong>System Account</strong>.</p>
  
  <p>I even tried logging in as different user but still displaying <strong>System Account</strong> as the current user.</p>
  
  <p>I tried following options : </p>
  
  <pre><code>SPUser user = workflowProperties.OriginatorUser;
  
  SPUser user = SPContext.Current.Web.CurrentUser;
  
  
  SPWeb web = SPContext.Current.Web;
  SPUser user = web.CurrentUser;
  
   SPContext.Current.Web.CurrentUser.LoginName;
  </code></pre>
  
  <p>But everything failed. Am sure that am doing something wrong. I don't know the correct procedure. Some procedures give me null or Object reference not set to an instance of the object or System Account details. I have even tried using elevated permission and its giving me null value. </p>
  
  <pre><code>SPSecurity.CodeToRunElevated elevatedSubmit = new SPSecurity.CodeToRunElevated(delegate
          {
              //SPUser user = SPContext.Current.Web.CurrentUser;
              //string strAssignedTo = user.Name;
  
              string sspURL = "http://localhost/PWA/default.aspx";
              SPSite site = new SPSite(sspURL);
              SPWeb web = site.OpenWeb();
              SPUser theUser = web.CurrentUser;
              string strUserName = theUser.Name;
          });
  
          SPSecurity.RunWithElevatedPrivileges(elevatedSubmit);
  </code></pre>
  
  <p>Am I supposed to add users explicitly as SPUser or any other changes before trying to retrieve current user via workflow ? </p>