【发布时间】:2014-04-14 20:13:39
【问题描述】:
我有一个启用安全字段的自定义字段,我还配置了安全配置文件以允许经理查看/更新此字段,但我还需要允许实体字段的所有者查看/更新此字段。 在我的情况下,这是帐户和联系人实体中的一个字段。
我尝试了几个插件在我的搜索中找到了它,但我不知道如何让它工作:
public void ShareSecureFieldWithOwner(Entity record)
{
// Any method that helps you find the AttributeMetadata Id
var attributeId = FindSecuredAttribute();
if (attributeId != Guid.Empty)
{
var userAccess = new PrincipalObjectAttributeAccess
{
AttributeId = attributeId,
ObjectId = record.ToEntityReference(),
PrincipalId = record.OwnerId,
UpdateAccess = true,
ReadAccess = true
};
context.AddObject(userAccess);
context.SaveChanges();
}
}
在此先感谢并感谢您的支持。
【问题讨论】: