<br />
<b>Deprecated</b>:  YoastSEO_Vendor\Symfony\Component\DependencyInjection\Container::__construct(): Implicitly marking parameter $parameterBag as nullable is deprecated, the explicit nullable type must be used instead in <b>/home/nubelus/sharedove/adisjugo/wp-content/plugins/wordpress-seo/vendor_prefixed/symfony/dependency-injection/Container.php</b> on line <b>60</b><br />
<br />
<b>Deprecated</b>:  YoastSEO_Vendor\League\OAuth2\Client\Provider\AbstractProvider::authorize(): Implicitly marking parameter $redirectHandler as nullable is deprecated, the explicit nullable type must be used instead in <b>/home/nubelus/sharedove/adisjugo/wp-content/plugins/wordpress-seo/vendor_prefixed/league/oauth2-client/src/Provider/AbstractProvider.php</b> on line <b>416</b><br />
<br />
<b>Deprecated</b>:  YoastSEO_Vendor\GuzzleHttp\Client::getConfig(): Implicitly marking parameter $option as nullable is deprecated, the explicit nullable type must be used instead in <b>/home/nubelus/sharedove/adisjugo/wp-content/plugins/wordpress-seo/vendor_prefixed/guzzlehttp/guzzle/src/Client.php</b> on line <b>181</b><br />
<br />
<b>Deprecated</b>:  YoastSEO_Vendor\GuzzleHttp\ClientInterface::getConfig(): Implicitly marking parameter $option as nullable is deprecated, the explicit nullable type must be used instead in <b>/home/nubelus/sharedove/adisjugo/wp-content/plugins/wordpress-seo/vendor_prefixed/guzzlehttp/guzzle/src/ClientInterface.php</b> on line <b>77</b><br />
{"id":527,"date":"2011-06-11T20:30:29","date_gmt":"2011-06-11T18:30:29","guid":{"rendered":"https:\/\/blog.sharedove.com\/adisjugo\/?p=527"},"modified":"2011-06-11T20:30:29","modified_gmt":"2011-06-11T18:30:29","slug":"managing-user-roles-and-permissions-through-sharepoint-object-model-in-sharepoint-2010","status":"publish","type":"post","link":"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/2011\/06\/11\/managing-user-roles-and-permissions-through-sharepoint-object-model-in-sharepoint-2010\/","title":{"rendered":"Managing user roles and permissions through SharePoint Object Model in SharePoint 2010"},"content":{"rendered":"<p>This post explains how to govern user roles and permissions from the SharePoint Object Model for SharePoint 2010. Creating SharePoint groups, adding users to the group, setting permissions for the group and check the existing permissions are explained.<\/p>\n<p><!--more--><\/p>\n<p>In this example, I&#8217;ll create a SharePoint group using the Object Model, add few users in that group &#8211; which will be single users as well as the whole AD groups, create a folder inside the existing SharePoint Document library, break it&#8217;s permissions inheritance to the parent Document Library, and create new permissions model adding to a single user full rights and to newly created SharePoint group read only rights. At the end, I&#8217;ll check permissions for any given user if (s)he has rights to do the certain operations on the folder items (read, add, edit&#8230;).<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"brush: csharp; title: Code sample:; notranslate\" title=\"Code sample:\">\nstring groupName1 = &quot;TestGroup1&quot;;\nSPUser ownerUser = m_SharePointWeb.SiteUsers&#x5B;&quot;PLAN-B\\ajugo&quot;];\n\n\/\/Add the group to the SPWeb web\nm_SharePointWeb.SiteGroups.Add(groupName1, ownerUser, ownerUser, &quot;Test group&quot;);\n\n\/\/Associate the group to the SPWeb\nm_SharePointWeb.AssociatedGroups.Add(m_SharePointWeb.SiteGroups&#x5B;groupName1]);\n\n\/\/add some more users and AD groups to this SP Group\nm_SharePointWeb.SiteGroups&#x5B;groupName1].AddUser(&quot;PLAN-B\\user1&quot;, &quot;user1&amp;lt;AT&amp;gt;plan-b-gmbh.com&quot;, &quot;User 1&quot;, &quot;User 1 from Management&quot;);\nm_SharePointWeb.SiteGroups&#x5B;groupName1].AddUser(&quot;PLAN-B\\user2&quot;, user2&amp;lt;AT&amp;gt;plan-b-gmbh.com, &quot;User 2&quot;, &quot;User 2 from Sales&quot;);\nm_SharePointWeb.SiteGroups&#x5B;groupName1].AddUser(&quot;PLAN-B\\user3&quot;, user3&amp;lt;AT&amp;gt;plan-b-gmbh.com, &quot;User 3&quot;, &quot;User 3 from backoffice&quot;);\n\nm_SharePointWeb.SiteGroups&#x5B;groupName1].AddUser(&quot;PLAN-B\\development&quot;, &quot;devgroup&amp;lt;AT&amp;gt;plan-b-gmbh.com&quot;, &quot;Development&quot;, &quot;The whole development AD Group&quot;);\n\n\/\/update groups\nm_SharePointWeb.SiteGroups&#x5B;groupName1].Update();\n\n\/\/update web\nm_SharePointWeb.Update();\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>To delete the group:<\/strong><\/p>\n<p>&nbsp;<\/p>\n<pre class=\"brush: csharp; title: Code sample:; notranslate\" title=\"Code sample:\">\nm_SharePointWeb.SiteGroups.Remove(groupName1);\nm_SharePointWeb.Update();\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Give permissions for groups and users to a SharePoint entity (SPWeb, SPList, SPListItem&#8230;)<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>In this example, I&#8217;ll create a folder inside the existing SharePoint library, break permissions inheritance on the folder level and give rights to one user and one SPGroup to this folder:<\/p>\n<pre class=\"brush: csharp; title: Code sample:; notranslate\" title=\"Code sample:\">\n\/\/get the existing document library\nSPListCollection docLibs = m_SharePointWeb.GetListsOfType(SPBaseType.DocumentLibrary);\nSPDocumentLibrary DocLib = (SPDocumentLibrary)(docLibs&#x5B;&quot;DocLibraryName&quot;]);\n\n\/\/create folder\nSPFolder folderTest2 = createDocumentLibraryFolder(DocLib.RootFolder, &quot;TestFolder&quot;);\n\n\/\/break role inheritance\nfolderTest2.Item.BreakRoleInheritance(false);\n\n\/\/folder update\nfolderTest2.Update();\n\n\/\/now, give FULL PERMISSIONS permissions to User1\nSPRoleDefinition role = m_SharePointWeb.RoleDefinitions&#x5B;&quot;Full Control&quot;];\nSPRoleAssignment roleAssignment;\nSPUser oneUser = m_SharePointWeb.SiteUsers&#x5B;@&quot;PLAN-Buser1&quot;];\nroleAssignment = new SPRoleAssignment(oneUser);\nroleAssignment.RoleDefinitionBindings.Add(role);\nfolderTest2.Item.RoleAssignments.Add(roleAssignment);\n\n\/\/and the readonly rights to the existibg SP Group\nSPGroup group2 = m_SharePointWeb.SiteGroups&#x5B;&quot;Test group&quot;];\nSPRoleAssignment group2RoleAssigment = new SPRoleAssignment(group2);\nSPRoleDefinition groupRoleDefinition = m_SharePointWeb.RoleDefinitions&#x5B;&quot;Read&quot;];\ngroup2RoleAssigment.RoleDefinitionBindings.Add(groupRoleDefinition);\nfolderTest2.Item.RoleAssignments.Add(group2RoleAssigment);\n\n\/\/folder update\nfolderTest2.Update();\n\n\/\/web update\nm_SharePointWeb.Update();\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Check if a specific user has a certain permissions on SPItem, SPList or SPWeb objects<\/strong><\/p>\n<p>&nbsp;<\/p>\n<pre class=\"brush: csharp; title: Code sample:; notranslate\" title=\"Code sample:\">\n\/\/check if the user has permissions to add new item in the folder\nSPUser userToCheck = m_SharePointWeb.SiteUsers&#x5B;@&quot;PLAN-Buser1&quot;]\n\nif (folderItem.DoesUserHavePermissions(userToCheck, SPBasePermissions.AddListItems))\n{\nTrace.WriteLine(&quot;User has permissions to add list items!!!&quot;);\n}\nelse\n{\nTrace.WriteLine(&quot;User DOES NOT HAVE permissions to add list items!!!&quot;);\n}\n<\/pre>\n<div class=\"fb-background-color\">\n\t\t\t  <div \n\t\t\t  \tclass = \"fb-comments\" \n\t\t\t  \tdata-href = \"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/2011\/06\/11\/managing-user-roles-and-permissions-through-sharepoint-object-model-in-sharepoint-2010\/\"\n\t\t\t  \tdata-numposts = \"59\"\n\t\t\t  \tdata-lazy = \"true\"\n\t\t\t\tdata-colorscheme = \"light\"\n\t\t\t\tdata-order-by = \"time\"\n\t\t\t\tdata-mobile=true>\n\t\t\t  <\/div><\/div>\n\t\t  <style>\n\t\t    .fb-background-color {\n\t\t\t\tbackground:  !important;\n\t\t\t}\n\t\t\t.fb_iframe_widget_fluid_desktop iframe {\n\t\t\t    width: 100% !important;\n\t\t\t}\n\t\t  <\/style>\n\t\t  ","protected":false},"excerpt":{"rendered":"<p>This post explains how to govern user roles and permissions from the SharePoint Object Model for SharePoint 2010. Creating SharePoint groups, adding users to the group, setting permissions for the group and check the existing permissions are explained.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[11],"tags":[54,55],"class_list":["post-527","post","type-post","status-publish","format-standard","hentry","category-development","tag-server-object-model","tag-sharepoint"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Managing user roles and permissions through SharePoint Object Model in SharePoint 2010 - Adis Jugo blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/2011\/06\/11\/managing-user-roles-and-permissions-through-sharepoint-object-model-in-sharepoint-2010\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Managing user roles and permissions through SharePoint Object Model in SharePoint 2010 - Adis Jugo blog\" \/>\n<meta property=\"og:description\" content=\"This post explains how to govern user roles and permissions from the SharePoint Object Model for SharePoint 2010. Creating SharePoint groups, adding users to the group, setting permissions for the group and check the existing permissions are explained.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/2011\/06\/11\/managing-user-roles-and-permissions-through-sharepoint-object-model-in-sharepoint-2010\/\" \/>\n<meta property=\"og:site_name\" content=\"Adis Jugo blog\" \/>\n<meta property=\"article:published_time\" content=\"2011-06-11T18:30:29+00:00\" \/>\n<meta name=\"author\" content=\"adis.jugo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"adis.jugo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/2011\/06\/11\/managing-user-roles-and-permissions-through-sharepoint-object-model-in-sharepoint-2010\/\",\"url\":\"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/2011\/06\/11\/managing-user-roles-and-permissions-through-sharepoint-object-model-in-sharepoint-2010\/\",\"name\":\"Managing user roles and permissions through SharePoint Object Model in SharePoint 2010 - Adis Jugo blog\",\"isPartOf\":{\"@id\":\"https:\/\/blog.sharedove.com\/adisjugo\/#website\"},\"datePublished\":\"2011-06-11T18:30:29+00:00\",\"author\":{\"@id\":\"https:\/\/blog.sharedove.com\/adisjugo\/#\/schema\/person\/a5ca63552094ce9d5a0440f3a1ac9a4c\"},\"breadcrumb\":{\"@id\":\"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/2011\/06\/11\/managing-user-roles-and-permissions-through-sharepoint-object-model-in-sharepoint-2010\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/2011\/06\/11\/managing-user-roles-and-permissions-through-sharepoint-object-model-in-sharepoint-2010\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/2011\/06\/11\/managing-user-roles-and-permissions-through-sharepoint-object-model-in-sharepoint-2010\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/blog.sharedove.com\/adisjugo\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Managing user roles and permissions through SharePoint Object Model in SharePoint 2010\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blog.sharedove.com\/adisjugo\/#website\",\"url\":\"https:\/\/blog.sharedove.com\/adisjugo\/\",\"name\":\"Adis Jugo blog\",\"description\":\"The Southern Side\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blog.sharedove.com\/adisjugo\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/blog.sharedove.com\/adisjugo\/#\/schema\/person\/a5ca63552094ce9d5a0440f3a1ac9a4c\",\"name\":\"adis.jugo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blog.sharedove.com\/adisjugo\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cc5a23cf1bd0b9d8401c9dd65c6c141041ec0c6e37eedbb511779e4a40a198fd?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cc5a23cf1bd0b9d8401c9dd65c6c141041ec0c6e37eedbb511779e4a40a198fd?s=96&d=mm&r=g\",\"caption\":\"adis.jugo\"},\"url\":\"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/author\/adisjugo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Managing user roles and permissions through SharePoint Object Model in SharePoint 2010 - Adis Jugo blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/2011\/06\/11\/managing-user-roles-and-permissions-through-sharepoint-object-model-in-sharepoint-2010\/","og_locale":"en_US","og_type":"article","og_title":"Managing user roles and permissions through SharePoint Object Model in SharePoint 2010 - Adis Jugo blog","og_description":"This post explains how to govern user roles and permissions from the SharePoint Object Model for SharePoint 2010. Creating SharePoint groups, adding users to the group, setting permissions for the group and check the existing permissions are explained.","og_url":"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/2011\/06\/11\/managing-user-roles-and-permissions-through-sharepoint-object-model-in-sharepoint-2010\/","og_site_name":"Adis Jugo blog","article_published_time":"2011-06-11T18:30:29+00:00","author":"adis.jugo","twitter_card":"summary_large_image","twitter_misc":{"Written by":"adis.jugo","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/2011\/06\/11\/managing-user-roles-and-permissions-through-sharepoint-object-model-in-sharepoint-2010\/","url":"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/2011\/06\/11\/managing-user-roles-and-permissions-through-sharepoint-object-model-in-sharepoint-2010\/","name":"Managing user roles and permissions through SharePoint Object Model in SharePoint 2010 - Adis Jugo blog","isPartOf":{"@id":"https:\/\/blog.sharedove.com\/adisjugo\/#website"},"datePublished":"2011-06-11T18:30:29+00:00","author":{"@id":"https:\/\/blog.sharedove.com\/adisjugo\/#\/schema\/person\/a5ca63552094ce9d5a0440f3a1ac9a4c"},"breadcrumb":{"@id":"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/2011\/06\/11\/managing-user-roles-and-permissions-through-sharepoint-object-model-in-sharepoint-2010\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.sharedove.com\/adisjugo\/index.php\/2011\/06\/11\/managing-user-roles-and-permissions-through-sharepoint-object-model-in-sharepoint-2010\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/2011\/06\/11\/managing-user-roles-and-permissions-through-sharepoint-object-model-in-sharepoint-2010\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog.sharedove.com\/adisjugo\/"},{"@type":"ListItem","position":2,"name":"Managing user roles and permissions through SharePoint Object Model in SharePoint 2010"}]},{"@type":"WebSite","@id":"https:\/\/blog.sharedove.com\/adisjugo\/#website","url":"https:\/\/blog.sharedove.com\/adisjugo\/","name":"Adis Jugo blog","description":"The Southern Side","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.sharedove.com\/adisjugo\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blog.sharedove.com\/adisjugo\/#\/schema\/person\/a5ca63552094ce9d5a0440f3a1ac9a4c","name":"adis.jugo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.sharedove.com\/adisjugo\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cc5a23cf1bd0b9d8401c9dd65c6c141041ec0c6e37eedbb511779e4a40a198fd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cc5a23cf1bd0b9d8401c9dd65c6c141041ec0c6e37eedbb511779e4a40a198fd?s=96&d=mm&r=g","caption":"adis.jugo"},"url":"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/author\/adisjugo\/"}]}},"_links":{"self":[{"href":"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/wp-json\/wp\/v2\/posts\/527","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/wp-json\/wp\/v2\/comments?post=527"}],"version-history":[{"count":0,"href":"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/wp-json\/wp\/v2\/posts\/527\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/wp-json\/wp\/v2\/media?parent=527"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/wp-json\/wp\/v2\/categories?post=527"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.sharedove.com\/adisjugo\/index.php\/wp-json\/wp\/v2\/tags?post=527"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}