....今天在写工作流的时候发现,用workflowproperty.web.CurrentUser,获得的总是系统帐户
经过一番研究终于找到了解决的方法
代码如下:
public SPUser GetCurrentUser()
{
SPUser user=null;
Microsoft.Office.Workflow.Utility.Contact con =
Microsoft.Office.Workflow.Utility.Contact.FromName(System.Threading.Thread.CurrentPrincipal.Identity.Name, workflowProperty.Web);
foreach (SPUser u in workflowProperty.Web.AllUsers)
{
if (u.LoginName == con.LoginName)
{
user = u;
break;
}
}
return user;
}