Workflow: Microsoft.SharePoint.SPException: User cannot be found.
Entrando nei worlflow settings di una lista SharePoint 2010 mi è comparso un errore con relativo correlation id. Nei log di SharePoint c'era questo messaggio:
Microsoft.SharePoint.SPException: User cannot be found.
at Microsoft.SharePoint.SPUserCollection.get_Item(String loginName)
at Microsoft.SharePoint.Workflow.SPWorkflowNoCodeSupport.LoadWorkflowBytesElevated(SPFile file, Int32 fileVer, Int32& userid, DateTime& lastModified)
at Microsoft.SharePoint.Workflow.SPWorkflowManager.AddDeclSiteTemplates(SPWeb web, String visibility, SPWorkflowTemplateCollection wftemplates, SPListTemplateType templateType)
at Microsoft.SharePoint.Workflow.SPWorkflowManager.RegisterNoCodeTemplates(SPWorkflowTemplateCollection wftemplates, SPWeb web)
at Microsoft.SharePoint.SPWeb.get_WorkflowTemplates()
at Microsoft.SharePoint.Workflow.SPWorkflowAssociationCollection.UpdateAssociationsToLatestVersion()
at Microsoft.SharePoint.ApplicationPages.WrkSetngPage.OnLoad(EventArgs ea)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
si trattava di una web application migrata a claims, a questo punto mi sono fatto elencare gli utenti con PowerShell:
ed ho rimosso gli utenti che avevano la login name non in formato claims. Nonostante questo continuavo ad avere l'errore.
Allora ho provato a farmi elencare i workflow associati alla lista da PowerShell per vedere se c'era qualche anomalia nelle proprietà:
e stranamente l'errore è scomparso.
Microsoft.SharePoint.SPException: User cannot be found.
at Microsoft.SharePoint.SPUserCollection.get_Item(String loginName)
at Microsoft.SharePoint.Workflow.SPWorkflowNoCodeSupport.LoadWorkflowBytesElevated(SPFile file, Int32 fileVer, Int32& userid, DateTime& lastModified)
at Microsoft.SharePoint.Workflow.SPWorkflowManager.AddDeclSiteTemplates(SPWeb web, String visibility, SPWorkflowTemplateCollection wftemplates, SPListTemplateType templateType)
at Microsoft.SharePoint.Workflow.SPWorkflowManager.RegisterNoCodeTemplates(SPWorkflowTemplateCollection wftemplates, SPWeb web)
at Microsoft.SharePoint.SPWeb.get_WorkflowTemplates()
at Microsoft.SharePoint.Workflow.SPWorkflowAssociationCollection.UpdateAssociationsToLatestVersion()
at Microsoft.SharePoint.ApplicationPages.WrkSetngPage.OnLoad(EventArgs ea)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
PowerShell
$w=get-spweb http://sgart.sharepoint.local
$w.SiteUsers | select id, loginname, name
Allora ho provato a farmi elencare i workflow associati alla lista da PowerShell per vedere se c'era qualche anomalia nelle proprietà:
PowerShell
$l = $w.Lists["contracts"]
$l.WorkflowAssociations