根据您的确认, 该问题已经通过我们所提供的方案进行修改后测试通过, 问题解决.

以下为该问题的产生原因:

SharePoint 2013使用的默认认证机制与2007不一样,  2007使用的是Windows 经典模式身份验证, 2013使用的是基于声明的安全认证机制. 该机制导致内部的登录名的形式为: i:0#.w|<account> 而非<account> 因为其内部代码会进行转化, 您在页面上不会看到这种表现形式. 因此, 在尝试将该用户名赋值给AssignedTo时, SharePoint利用传统的域\用户名调用GetByLoginNoThrow但无法找到该用户, 因此会显示为空. 但是如果利用SPUser类, 其会在内部逻辑进行处理. 这也是直接手动赋值产生问题的原因.

详细表现形式如下:

1) SharePoint 2013 引入了一种新的基于声明的安全认证机制. SharePoint 2013 中的用户身份验证是验证请求访问 SharePoint Web 应用程序的用户的身份的过程。身份验证提供程序会向经过身份验证的用户颁发一个安全令牌,该令牌将封装一组有关用户的基于声明的断言,并用于验证分配给用户的一组权限。SharePoint 2013 中的用户授权是一个确定可对 SharePoint Web 应用程序中指定源执行定义的操作的用户的过程。SharePoint 2013 支持基于以下方法的用户身份验证:  Windows 声明  基于安全声明标记语言 (SAML) 的声明  基于表单的身份验证声明 这些基于声明的身份验证方法现在是为 SharePoint 2013 建议的身份验证方法。 SharePoint 2013 的应用程序身份验证和服务器间身份验证功能需要基于声明的身份验证。为此,基于声明的身份验证是 SharePoint 2013 中针对新 Web 应用程序的默认身份验证。当您在管理中心中创建 Web 应用程序时,您只能为基于声明的身份验证指定身份验证方法。虽然 Windows 经典模式身份验证仍在 SharePoint 2013 中可用且可通过 Windows PowerShell 进行配置,但建议您使用基于声明的身份验证。Windows 经典模式身份验证在 SharePoint 2013 中已被弃用。

2) 有关声明的详细解释: http://msdn.microsoft.com/en-us/library/ff359101.aspx

3) 基于声明的认证架构: http://msdn.microsoft.com/en-us/library/ff359108.aspx

笔误: 更新taskProperties.AssignedTo = @”i:0#.w|wtc\setup1.moss”为taskProperties.AssignedTo = @”i:0#.w|wtc\test2.moss”

Thanks & Regards, Jiankui Guo | P +86 510 6665 7620

From: Jiankui Guo Sent: Friday, April 18, 2014 3:55 PM To: 'Bird Han 韩强' Cc: MSSolve Case Email; Jet Zhu; Qingyan Liang Subject: RE: [REG:114041711371429] Prem/SharePoint 2013/Workflow development issue

Hi Bird,

根据代码, 日志以及本地简单代码模拟测试的相关分析:

1) taskProperties.AssignedTo的值实际上已经传入内部的方法中 Workflow runtime已经开始调用CreateTask 并且我们已经可以看到实际赋予AssignedTo的值为WTC\test2.moss. 参考随后的日志信息.

Entering: GetByLoginNoThrow(WTC\test2.moss) SqlCommand: ; EXEC proc_secgetprincipalbylogin 'fc09578e-4e68-49d4-8a3a-7092669049ad', @login, 0, 0, @RequestGuid OUTPUT ConnectionString: 'Data Source=wtcsps99;Initial Catalog=WSS_Content;Integrated Security=True;Enlist=False;Pooling=True;Min Pool Size=0;Max Pool Size=100;Connect Timeout=15'    Partition: fc09578e-4e68-49d4-8a3a-7092669049ad ConnectionState: Closed ConnectionTimeout: 15 SqlCommand: 'proc_SecGetPrincipalByLogin'     CommandType: StoredProcedure CommandTimeout: 0     Parameter: Type: Int Size: 0 Direction: ReturnValue Value: ''     Parameter: Type: UniqueIdentifier Size: 0 Direction: Input Value: 'fc09578e-4e68-49d4-8a3a-7092669049ad'     Parameter: Type: NVarChar Size: 4000 Direction: Input Value: 'WTC\test2.moss'     Parameter: Type: Bit Size: 0 Direction: Input Value: 'False'     Parameter: Type: Bit Size: 0 Direction: Input Value: 'False'     Parameter: Type: UniqueIdentifier Size: 0 Direction: Input Value: '680f889c-fac4-20f7-31a4-ef255c2f9782' SqlCommand StackTrace-Managed:    at Microsoft.SharePoint.Utilities.SqlSession.OnPreExecuteCommand(SqlCommand command)     at Microsoft.SharePoint.Utilities.SqlSession.ExecuteReader(SqlCommand command, CommandBehavior behavior, SqlQueryData monitoringData, Boolean retryForDeadLock)     at Microsoft.SharePoint.SPSqlClient.ExecuteQueryInternal(Boolean retryfordeadlock)     at Microsoft.SharePoint.SPSqlClient.ExecuteQuery(Boolean retryfordeadlock)     at Microsoft.SharePoint.Library.SPRequestInternalClass.GetUsersDataAsSafeArray(String bstrUrl, UInt32 dwUsersScope, UInt32 dwUserCollectionFlags, String bstrValue, UInt32 dwValue, UInt32& pdwColCount, UInt32& pdwRowCount, Object& pvarDataSet)     at Microsoft.SharePoint.Library.SPRequestInternalClass.GetUsersDataAsSafeArray(String bstrUrl, UInt32 dwUsersScope, UInt32 dwUserCollectionFlags, String bstrValue, UInt32 dwValue, UInt32& pdwColCount, UInt32& pdwRowCount, Object& pvarDataSet)     at Microsoft.SharePoint.Library.SPRequest.GetUsersDataAsSafeArray(String bstrUrl, UInt32 dwUsersScope, UInt32 dwUserCollectionFlags, String bstrValue, UInt32 dwValue, UInt32& pdwColCount, UInt32& pdwRowCount, Object& pvarDataSet)     at Microsoft.SharePoint.SPUser.InitMember()     at Microsoft.SharePoint.SPUser..ctor(SPWeb web, SPSecurableObject scope, String strIdentifier, Object[,] arrUsersData, UInt32 index, Int32 iByParamId, String strByParamSID, String strByParamEmail, SPUserCollectionType userCollectionType, SPUserCollectionFlags ucf, Boolean isSiteAuditor)     at Microsoft.SharePoint.SPUserCollection.GetByLoginNoThrow(String loginName, SPUserCollectionFlags ucf)     at Microsoft.SharePoint.Workflow.SPWinOETaskService.UpdateTaskInternal(Guid taskId, SPWorkflowTaskProperties properties, Boolean fSetWorkflowFinalize, Boolean fCreating, HybridDictionary specialPermissions)     at Microsoft.SharePoint.Workflow.SPWinOETaskService.CreateTaskWithContentTypeInternal(Guid taskId, SPWorkflowTaskProperties properties, Boolean useDefaultContentType, SPContentTypeId ctid, HybridDictionary specialPermissions)     at Microsoft.SharePoint.Workflow.SPWinOETaskService.CreateTask(Guid taskId, SPWorkflowTaskProperties properties, HybridDictionary specialPermissions)     at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)     at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)     at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)     at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)     at System.Workflow.Activities.CallExternalMethodActivity.Execute(ActivityExecutionContext executionContext)     at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)     at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)     at System.Workflow.Runtime.Scheduler.Run()

2) 请直接更新以下代码尝试: taskProperties.AssignedTo = @”i:0#.w|wtc\test2.moss”

3) 请将如下代码更新为:

if (!currentApprover.IsGroup)             {                 //Replace the CurrentApprover LogonName to Delegation                 workflowHelper.getDelegation(currentApprover, context);                 SPUser currentUser = workflowProperties.Web.EnsureUser(currentApprover.LogonName);             }

taskProperties.AssignedTo = currentApprover.LogonName;

=             if (!currentApprover.IsGroup)             {                 //Replace the CurrentApprover LogonName to Delegation                 workflowHelper.getDelegation(currentApprover, context);                 SPUser currentUser = workflowProperties.Web.EnsureUser(currentApprover.LogonName);                 taskProperties.AssignedTo = currentUser.LoginName;             }             else                 taskProperties.AssignedTo = currentApprover.LogonName;

4) 测试效果. 我的repro代码能够重现并修复.

问题定义: AssignedTo in SPWorkflowTaskProperties doesn't work for user but for sharepoint group. Environment: SharePoint 2013 Workflow Type: SharePoint 2010

//AssignedTo of the task created by workflow is blank taskProperties.AssignedTo = "wtc\\setup1.moss"; //AssignedTo of the task created by workflow is expected. "IT Department Accountant Group" is a group in SharePoint taskProperties.AssignedTo = "IT Department Accountant Group";

wtc\\setup1.moss has permisisons for the site

问题范围: Suggest workaround or solution to fix this issue

如果您对以上的问题范围界定有任何异议,请尽快告知.如果您有其他任何疑问,也欢迎随时与我联系.

05-11 22:03