Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to manage column based access control in Sharepoint lists?

Tags:

sharepoint

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 of users (Administrators). Is there a way to set column based access control?

like image 745
kyrisu Avatar asked Jun 15 '09 17:06

kyrisu


People also ask

How do I set column level permissions in SharePoint?

You can't set column level permissions in SharePoint. There are ways to show and hide columns, but we can't set column level permissions in SP. There are workarounds (hacks) to set permissions on Views, but it's not the column level permissions you are looking for.

How do I control access to a SharePoint list?

On the permissions page for the list, on the Edit tab, click Grant Permissions. Type the name of the group or the individual you want to grant access to in the Users/Groups box. Choose the level of permissions you want the group or individuals to have. Click OK.

How do I manage columns in SharePoint?

To modify a column, click the column in the list, click Modify, and then make the appropriate changes. Note: Some options for adding, removing, or modifying columns are available only when you publish to a SharePoint site.


1 Answers

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

<FieldTypes>

  <FieldType>
    <Field Name="TypeName">MyInteger</Field>
    <Field Name="ParentType">Integer</Field>
    ...
    <Field Name="FieldTypeClass">xxx</Field>
  </FieldType>

and in sitecolumns.xml

  <Field ID="xxx"
      Name="xxx"
      DisplayName="xxx
      Description="xxx"
      Group="xxx
      Type="MyInteger"    
      DisplaceOnUpgrade="TRUE"
  />

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
    }
}
like image 171
Johan Leino Avatar answered Nov 15 '22 07:11

Johan Leino