2

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.

1 Answer 1

1

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());
}
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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