只是想澄清 GotDibb 的数据是正确的,即使我的问题与之相矛盾。
我创建了一个 UserIdTest 插件如下
public void Execute(IServiceProvider serviceProvider)
{
var context = serviceProvider.GetContext();
var service = serviceProvider.GetService(context);
var iUser = service.Retrieve("systemuser", context.InitiatingUserId, new ColumnSet("fullname"));
var uUser = service.Retrieve("systemuser", context.UserId, new ColumnSet("fullname"));
throw new Exception(string.Format("Initiating: {0}, User: {1}",
iUser.GetAttributeValue<string>("fullname"),
uUser.GetAttributeValue<string>("fullname")));
}
我进行了与 GotDibbs 相同的测试,得到了相同的答案,这让我感到困惑,因为如果我没有以某种方式得到不同的答案,我就不会问这个问题。但后来我意识到我看到的问题是由递归插件引起的。
对插件的第一次调用按预期工作,但是当插件触发对插件的另一个调用时,它使用了插件的上下文用户凭据(这是有道理的)并丢失了模拟用户 ID 的凭据。这是一张表格,希望能帮助澄清发生了什么
首先是初始插件调用:
+--------------------+------------ +----------------------+----------------------------------------+
| Org Service | Org Service | Plugin Step Run | Results |
| Client Credentials | CallerId | in User's Context | |
+--------------------+------------ +----------------------+----------------------------------------+
| | | | InitiaitingUser : ServiceAccount |
| ServiceAccount | None | PluginServiceAccount | |
| | | | UserId : PluginServiceAccount |
+--------------------+------------ +----------------------+----------------------------------------+
| | | | InitiaitingUser : UserBob |
| ServiceAccount | UserBob | PluginServiceAccount | |
| | | | UserId : PluginServiceAccount |
+--------------------+------------ +----------------------+----------------------------------------+
第二个插件深度> 1
+--------------------+------------ +----------------------+----------------------------------------+
| Org Service | Org Service | Plugin Step Run | Results |
| Client Credentials | CallerId | in User's Context | |
+--------------------+-------------+----------------------+----------------------------------------+
| | | | InitiaitingUser : PluginServiceAccount |
| ServiceAccount | None | PluginServiceAccount | |
| | | | UserId : PluginServiceAccount |
+--------------------+-------------+----------------------+----------------------------------------+
| | | | InitiaitingUser : PluginServiceAccount |
| ServiceAccount | UserBob | PluginServiceAccount | |
| | | | UserId : PluginServiceAccount |
+--------------------+-------------+----------------------+----------------------------------------+