This project has moved. For the latest updates, please go here.

AddPermission to folder

Feb 18, 2013 at 10:08 PM
So I've figured out how to add folders and sub-folders, and copy files into them using UpdateListItems and CopyIntoItemsLocal.

What I need to do now is set up some custom permissions on the folders and files.

I put together a function as below but for some reason I'm getting error for status, undefined for the xml, and the error log in firebug is showing me "NetworkError: 500 Internal Server Error - https://mydomain/mysite/mysubsite/submissions/_vti_bin/Permissions.asmx"
    function makecontributor(folder,user) {
            operation: 'AddPermission',
            async: false, 
            objectType: 'List',
            objectName: folder,
            permissionIdentifier: user,
            permissionType: 'user',
            permissionMask: 1011028719,
            completefunc: function(xData, Status) {
                document.getElementById("usernames").value += ('  --Setting permission on '+folder+' for '+user+' to '+"\n");
                document.getElementById("usernames").value += ('  --Status=' + Status + " XML=" + xData.responseXML.xml+"\n");      
Feb 18, 2013 at 11:08 PM
Note that ObjectName has to be "A string that contains the name of the list or site." You can't specify a folder. This operation can ony be used on a Site or Web.

Feb 20, 2013 at 9:39 AM
Ah, I thought a file/folder counted as a list item. Ok - back to the drawing board - got to figure out how to set permissions on folders and files!
Feb 20, 2013 at 5:35 PM
You may be running into this problem. Look over this thread and see if it helps you find the answer:

Feb 21, 2013 at 6:06 PM
Well - I've done an awful lot of research and it seems there is no web service to do this.

Two options:
  1. Create a custom webservice. I don't know how to do this, I don't have VisualStudio or any experience of it, and may not even have permissions to do that.
  2. Create an object model implementation. Which I believe imvolves writing aspx code and sticking it in to the SP installation. Again, I've no idea how to do that!
So unless anyone wants to give me an aspx crash course for dummies... I think I need to write this one off. Which means doing things in a much longer manner - by hand :(
Feb 22, 2013 at 5:24 PM
Edited Feb 22, 2013 at 10:04 PM
You're right that there isn't a Web Service operation for this. Depending on how many folders you are thinking of and why, you might want to consider separate Document Libraries instead. Item level permissions (folders are items) can get extremely messy extremely fast.

Feb 22, 2013 at 9:52 PM
Not practical I'm afraid. I'm learning and web parts and asp etc. fun :)
Feb 24, 2013 at 2:23 AM
You may be able to use JS CSOM and still apply permissions to your folders/items using this class:

I haven't tried it but it looks promising.