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

I have a 2010 site that has many documents in many different folders. I believe a number of them have broken permission inheritence. Is there a way i can code a C# console app to utilise client object model, go through my libraries and check if a document has unique permissions?

I have done the standard google, checked msdn and nothing turns up. It seems to be a unique problem.

Thanks for any help you can provide.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Actually yes it is (details here http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecurableobject.hasuniqueroleassignments(v=office.14).aspx). One important note though - simple Load statement with a ListItemCollection parameter (i.e. ctx.Load(lic)) does not load 4 properties of ListItem by default when you return list items: DisplayName, EffectiveBasePermissions, HasUniqueRoleAssignments, and RoleAssignments. If you tried to reference them in your code, you will get a Property not initialized error.

To get beyond that you need to specifically ask to have them included when you define your query using, by example the IncludeWithDefaultProperties

function retrieveProperties () {

    var clientContext = new SP.ClientContext('/sites/TestWebs/TestWeb1');
    this.oWebsite = clientContext.get_web();

    clientContext.load(oWebsite, 'Title', 'HasUniqueRoleAssignments');

    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}

function onQuerySucceeded() {
    alert('Title: ' + oWebsite.get_title() + 
    '\nUnique role assignments: ' + oWebsite.get_hasUniqueRoleAssignments());
}

function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
share|improve this answer
    
I've updated the response with an example straight from MSDN msdn.microsoft.com/en-us/library/ee534974(v=office.14).aspx –  C. Marius - MVP Apr 8 '13 at 13:56
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.