views:

92

answers:

2

Don't know how to google for such, but is there a way to query all the items where

  • Permissions are unique to listitem
  • These unique permissions contains assignment for specific group X.
A: 

I don't think you can do this by shaping a CAML query and using the SPQuery object to get the items in this way.

My thinking would be to get all items, and loop through them testing for the HasUniqueRoleAssignments and RoleAssignments properties.

Paul Lucas
Aww, that looks like too much if I want to, when group X changes, update all items (set some stuff) where group X had permissions.
Janis Veinbergs
+1  A: 

You will have to loop through the items and inspect the permissions item per item and update them if relevant. The more items you have the longer it takes. So not really a great solution.

An other solution is using the credentials of a user that is only member of group x. SharePoint automatically takes permissions into account. So if you connect to the list using that user, you should only get the items on which the user has permissions. Use the NetworkCredentials class for doing this.

Then use a CAML query to update your items.

--W

W0ut
Really, that looks promising and simple! Thank you.In my case this helps.
Janis Veinbergs
Also, i don't necesarilly need to use NetworkCredentials class, as there is SPSite constructor overload that takes into account SPUserToken (http://msdn.microsoft.com/en-us/library/ms436101.aspx) (something like log in as user X).
Janis Veinbergs