How to manage column based access control in Sharepoint lists?

后端 未结 2 1324
北恋
北恋 2020-12-06 08:12

I\'m making issue tracking portal based on Sharepoint. Users should be able to add entries, but in the entry itself I want one column to only be visible to a specific group

2条回答
  •  既然无缘
    2020-12-06 08:25

    As far as I know that is not available in the standard platform. What you can do on the other hand is to handcraft your own fieldcontrol

    So in custom fieldtypes.xml

    
    
      
        MyInteger
        Integer
        ...
        xxx
      
    

    and in sitecolumns.xml

      
    

    and in your fieldcontrol

    public class MyInteger: SPFieldNumber
    {
        public MyInteger(SPFieldCollection fields, string fieldName)
            : base(fields, fieldName)
        {
        }
    
        public MyInteger(SPFieldCollection fields, string typeName, string displayName)
            : base(fields, typeName, displayName)
        {
        }
    
    
        public override BaseFieldControl FieldRenderingControl
        {
            [SharePointPermission(SecurityAction.LinkDemand, ObjectModel = true)]
            get
            {
                Microsoft.SharePoint.WebControls.BaseFieldControl ctl = 
                   new MyIntegerControl();
                ctl.FieldName = InternalName;
                return ctl;
    
            }
        }
    
        }
    

    and in the MyIntegerControl you can do whatever you want (lots of overrides), but an example is:

    protected override void CreateChildControls()
    {
        base.CreateChildControls();
        if (this.ControlMode == SPControlMode.New || 
            this.ControlMode == SPControlMode.Display)
        {
          // check that use is admin and display value
        }
    }
    

提交回复
热议问题