在自定义BCS / .net类上实现安全性?

我正在实现一个自定义BCS模型来从后端系统获取数据.由于后端使用它自己的用户管理,我通过服务帐户访问它.

所有这些都很好,并允许我将数据提取到SharePoint.但是因为它是通过服务帐户引导的,所以每个人都可以访问它,这很糟糕.

任何人都可以给我一些方法来实现吗?后端没有给我NT ACL,但我想知道我是否可以以某种方式“伪造”它们? (基本上说“这个NT组有读取权限”已经足够了).

我知道搜索结果的ISecurityTrimmer2,但理想情况下我想要涵盖BCS模型中的安全性,以便它也适用于外部列表.我想避免使用安全存储并将每个用户映射到后端.

最佳答案 得到了答案
here.我可以将BCS模型中的字段设置为WindowsSecurityDescriptorField,然后我可以在我的BCS方法中使用自定义代码来创建ACL:

Byte[] GetSecurityDescriptor(string domain, string username)
{
    NTAccount acc = new NTAccount(domain, username);
    var sid = (SecurityIdentifier)acc.Translate(typeof(SecurityIdentifier));
    CommonSecurityDescriptor sd = new CommonSecurityDescriptor(false, false,
        ControlFlags.None,sid,null, null, null);
    sd.SetDiscretionaryAclProtection(true, false);

    //Deny access to everyone
    SecurityIdentifier everyone = new SecurityIdentifier(
        WellKnownSidType.WorldSid, null);
    sd.DiscretionaryAcl.RemoveAccess(AccessControlType.Allow, everyone, 
      unchecked((int)0xffffffffL), InheritanceFlags.None, PropagationFlags.None);

    //Grant full access to specified user
    sd.DiscretionaryAcl.AddAccess(AccessControlType.Allow, sid,
      unchecked((int)0xffffffffL), InheritanceFlags.None, PropagationFlags.None);

    byte[] secDes = new Byte[sd.BinaryLength];
    sd.GetBinaryForm(secDes, 0);

    return secDes;
}

这很好用,并允许我在后端系统和Active Directory之间翻译用户后创建自定义ACL.

如果将安全性作为BCS模型的一部分,我仍然有兴趣听听是否有人有其他办法.

点赞