Hello,
I'm using Sharepoint 2013 and Visual Studio 2012 to deploy a workflow on a list. I start the workflow programmatically, but some users haven't permission to start it. So I've introduced the SPSecurity.RunWithElevatedPrivileges. In detail the code is:
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(properties.OpenWeb().Site.ID))
{
using (SPWeb web = site.OpenWeb(properties.RelativeWebUrl))
{
var wsm = new Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager(web);
var subscription = wsm.GetWorkflowSubscriptionService().GetSubscription(new Guid(workflowGuid));
var wfi = wsm.GetWorkflowInstanceService();
var payload = new Dictionary<string, object>();
wfi.StartWorkflowOnListItem(subscription, itemCopiedID, payload);
}
}
});
The error is System.UnauthorizedAccessException. The RunWithElevatedPrivileges impersonate the SHAREPOINT\system account, it's possible that this account haven't permission to start workflow? If I use another method to impersonate users (only users that are site administrator) and after start workflow, with some users the workflow start but with one of those don't start.
Thanks, Danilo