Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How can you efficiently determine if any of the items in a List don't inherit their security from the List?

You could use SPListItem.HasUniqueRoleAssignments but this would require iterating through all items in the List.

share|improve this question
add comment

2 Answers

up vote 6 down vote accepted

Leading on from @tylerrrr07's answer, there's another overload of GetItemsWithUniquePermissions which may be of use to you:

MSDN: SPList.GetItemsWithUniquePermissions Method (int maxItemToReturn, bool folderOnly)

You could then avoid the potentially huge result set from running the method by using the following:

SPList.GetItemsWithUniquePermissions(1, false).Count == 1
share|improve this answer
1  
If this actually bypasses the SPQueryThrottledException issue (which I imagine it should) its a great solution. Thanks for pointing this out. –  ToddersLegrande Feb 29 '12 at 14:45
    
@tylerrrr07: Thanks. The exception description seems to indicate that it's triggered by the size of its own result set; but of course that's no guarantee. –  Stuart Pegg Feb 29 '12 at 14:56
add comment

Haven't tested it myselt but it looks like you could do something along the lines of

SPList.GetItemsWithUniquePermissions().Count > 0;
share|improve this answer
    
A minor problem with this solution is that all the list items have with item-level permissions are returned by the function (which may be all of them). This in turn may cause it to throw an SPQueryThrottledException: msdn.microsoft.com/en-us/library/ee572463.aspx –  Stuart Pegg Feb 29 '12 at 14:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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