0

As per my requirement i need to remove a particular user from his permissions from document library item .There is a field called Assigned_To in my docu.lib and I DONT want HIM to access the docu.item based on a status column. ie, when the value of status column is set to deallocated, i need to remove this user from accessing this item.

How this can be achieved using C#? i tried the below code:

    for(int i = newFile.Item.RoleAssignments.Count - 1; i >= 0; i--)
             {
     newFile.Item.RoleAssignments.RemoveById(newFile.Item.
     RoleAssignments[i].Member.ID);
                }

but this code somehow didn't work.

is there any otehr way of achieving this? I cant use removeallassociations of this partiular item.Thats the reason I am trying to achieve for a single user.

1

Please use below code:

for(int i = newFile.Item.RoleAssignments.Count - 1; i >= 0; i--)
   {
     newFile.Item.RoleAssignments.Remove("Pass your SPUser Object");
   }

Hope it works for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.