0

I would like to set the read permissions to all authenticated users on a site collection.

First I was using this code below, but I got an exception that this permission level is not existed.

roleAssignment.RoleDefinitionBindings.Add(web.RoleDefinitions["Read"]);

When I translate the permission level "Read" to dutch "Lezen" it works (see code below). But I do not would like to hardcode some language. Is it possible to set permissions without using explicit the language of the site?

roleAssignment.RoleDefinitionBindings.Add(web.RoleDefinitions["Lezen"]);

1 Answer 1

0

Try using SPRoleType

I hope this helps, I haven't tried it out, but here is an example :

The way that would cause localisation issues :

web.RoleDefinitions["Read"];

The way that wouldn't cause localisation issues :

web.RoleDefinitions.GetByType(SPRoleType.Reader);

Taken from here :

http://blog.myitechnology.com/2010/04/sharepoint-tips-working-in-localized.html

It's a good read :)

Here is a full list of roles :

https://msdn.microsoft.com/EN-US/library/microsoft.sharepoint.sproletype.aspx

And some help with dealing with it programatically

https://tjendarta.wordpress.com/tag/sproletype/

Kind regards,

Your Answer

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

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