/// <summary>
/// Get current user in workflow sharepoint context
/// </summary>
/// <param name="workflowProperties"></param>
/// <returns></returns>
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 = usersInSite.Count;
for (int iCnt = 0; iCnt <= countUsers - 1; iCnt++)
{
if (usersInSite[iCnt].ID == iUserID)
{
return workflowProperties.Web.SiteUsers[iCnt];
}
}
return null;
}
Refer from
http://www.sharepointkings.com/2008/08/how-to-get-currently-logged-in-user-in.html
0 comments :
Post a Comment