NOTE: This solution doesn't work for Site workflows
You can use this code snippet (Get current user in workflow sharepoint context (C#))
public static SPUser GetCurrentUserInWorkflow(Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties workflowProperties)
{
string ModifiedbyUserName = Convert.ToString(workflowProperties.Item.GetFormattedValue("Modified By"));
string[] strChar = { "ID=" };
string[] strChars = ModifiedbyUserName.Split(strChar, StringSplitOptions.None);
Int32 iUserID = Convert.ToInt32(strChars[1].Substring(0, strChars[1].IndexOf("\"")));
SPUserCollection usersInSite = workflowProperties.Web.SiteUsers;
int countUsers = usersI nSite.Count;
for (int iCnt = 0; iCnt <= countUsers - 1; iCnt++)
{
if (usersInSite[iCnt].ID == iUserID)
{
return workflowProperties.Web.SiteUsers[iCnt];
}
}
return null;
}
Basically you are checking last user who modified workflow item. However this will not work if you need to find current user on workflow start but then you can use:
workflowProperties.OriginatorUser.ID
workflowProperties.OriginatorUser.Name
workflowProperties.OriginatorUser.ID.LoginName
You can find more detailed explanation here: How to get currently logged-in user in workflow
You only need to call user profile service if you require some additional user info for your workflow (eg. Department, Work Phone...)