{"id":343,"date":"2011-05-25T18:08:05","date_gmt":"2011-05-25T18:08:05","guid":{"rendered":"http:\/\/www.myfatblog.co.uk\/?p=343"},"modified":"2011-05-25T18:11:40","modified_gmt":"2011-05-25T18:11:40","slug":"spweb-associatedmembergroup-returning-incorrect-information","status":"publish","type":"post","link":"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/05\/spweb-associatedmembergroup-returning-incorrect-information\/","title":{"rendered":"SPWeb.AssociatedMemberGroup returning incorrect information."},"content":{"rendered":"<p>Just recently, I\u00e2\u20ac\u2122ve been working on a solution for a client that wanted to create a meetings portal for a very formal meeting process. The basic breakdown of the site is as follows, A top level Site Collection housing <a href=\"http:\/\/meetings.contoso.com\">http:\/\/meetings.contoso.com<\/a>.<\/p>\n<p>This site was created with the default groups of Meetings Visitors, Members and Owners. Then for each particular committee, there was a sub-web with <strong><em>Unique<\/em><\/strong>&#160; permissions, thus ensuring separation of the committees and ensuring&#160; that access was given to the correct groups.<\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <a href=\"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/SPWeb.AssociatedMemberGroup-returning-i_10574\/image.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"image\" border=\"0\" alt=\"image\" src=\"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/SPWeb.AssociatedMemberGroup-returning-i_10574\/image_thumb.png\" width=\"244\" height=\"175\" \/><\/a><\/p>\n<p>Under each subweb, Meeting workspaces are created for each of the monthly meetings and the following process is followed:-<\/p>\n<ol>\n<li>Meeting organiser uploads Meeting minutes and supporting documents. <\/li>\n<li>Workflows triggered inviting comment from the members group. <\/li>\n<li>Members update with comments <\/li>\n<li>Comments are approved\/rejected and the content agreed. <\/li>\n<li>Site is locked down as Read Only for the AssociatedMembers group <\/li>\n<\/ol>\n<p>As you can see from the above, steps 1-4 are fairly standard out of the box SharePoint behaviours. The problem comes in Step 5. Not because we\u00e2\u20ac\u2122re doing anything strange with security, but because we\u00e2\u20ac\u2122re not doing it through the UI. Rather the client requirements were to provide a meeting management webpart that included an option to lock the site down through some custom code once certain attributes were valid.<\/p>\n<p>To verify the correct behaviour as experienced through the UI,&#160; navigate to the \/Commitee2\/Mtg1 subweb and choose Site Actions\/Site permissions, you\u00e2\u20ac\u2122ll see the usual UI page showing you that the site is \u00e2\u20ac\u0153<strong><em>Inheriting it\u00e2\u20ac\u2122s permissions from it\u00e2\u20ac\u2122s parent (Committee2)<\/em><\/strong>\u00e2\u20ac\u009d and underneath this warning, you\u00e2\u20ac\u2122ll see Committee2 Owners, Members and Visitors. This is as we\u00e2\u20ac\u2122d expect.<\/p>\n<p>The problem comes in the custom code for the site which breaks inheritance and then resets the permissions for each of the groups. The groups are obtained from the SPWeb object for the current site from context.<\/p>\n<pre class=\"csharpcode\">SPWeb currWeb = SPContext.Current.Web;\r\n\r\n<span class=\"kwrd\">string<\/span> associatedMemberGroupName = currWeb.AssociatedMemberGroup;\r\n<span class=\"kwrd\">string<\/span> associatedOwnerGroupName = currWeb.AssociatedOwnerGroup;\r\n<span class=\"kwrd\">string<\/span> associatedVisitorGroupName = currWeb.AssociatedVisitorGroup;<\/pre>\n<style type=\"text\/css\">\n<p>.csharpcode, .csharpcode pre\n{\n\tfont-size: small;\n\tcolor: black;\n\tfont-family: consolas, \"Courier New\", courier, monospace;\n\tbackground-color: #ffffff;\n\t\/*white-space: pre;*\/\n}\n.csharpcode pre { margin: 0em; }\n.csharpcode .rem { color: #008000; }\n.csharpcode .kwrd { color: #0000ff; }\n.csharpcode .str { color: #006080; }\n.csharpcode .op { color: #0000c0; }\n.csharpcode .preproc { color: #cc6633; }\n.csharpcode .asp { background-color: #ffff00; }\n.csharpcode .html { color: #800000; }\n.csharpcode .attr { color: #ff0000; }\n.csharpcode .alt \n{\n\tbackground-color: #f4f4f4;\n\twidth: 100%;\n\tmargin: 0em;\n}\n.csharpcode .lnum { color: #606060; }<\/style>\n<p>When stepping through the code, I expected these objects to whole values similar to \u00e2\u20ac\u0153Committee2 Members Group\u00e2\u20ac\u009d which should be the value inherited from the Parent. Instead, I\u00e2\u20ac\u2122m receiving \u00e2\u20ac\u0153Meetings Members Group\u00e2\u20ac\u009d which is the Site Collection root group, completely ignoring the inheritance of the Parent.<\/p>\n<p>Bizarrely, if you instantiate an SPWeb against currWeb.ParentWeb and look at the same groups, you get the values that you\u00e2\u20ac\u2122d expect.<\/p>\n<p>&#160;<\/p>\n<h2>In Summary:-<\/h2>\n<p>Instantiating SPWeb.AssociatedMemberGroup does not return the value expected when inheritance is broken even when existing values are copied.<\/p>\n<h2>Workaround:-<\/h2>\n<p>It may be possible to look at the ParentWeb object and use it\u00e2\u20ac\u2122s values instead, however this is very Situation specific!<\/p>\n<p>Paul.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Just recently, I\u00e2\u20ac\u2122ve been working on a solution for a client that wanted to create a meetings portal for a very formal meeting process. The basic breakdown of the site is as follows, A top level Site Collection housing http:\/\/meetings.contoso.com. This site was created with the default groups of Meetings Visitors, Members and Owners. Then &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/05\/spweb-associatedmembergroup-returning-incorrect-information\/\">Continue reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[3,13,31,35],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SPWeb.AssociatedMemberGroup returning incorrect information. - Blog of an overweight SharePoint addict<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/05\/spweb-associatedmembergroup-returning-incorrect-information\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SPWeb.AssociatedMemberGroup returning incorrect information. - Blog of an overweight SharePoint addict\" \/>\n<meta property=\"og:description\" content=\"Just recently, I\u00e2\u20ac\u2122ve been working on a solution for a client that wanted to create a meetings portal for a very formal meeting process. The basic breakdown of the site is as follows, A top level Site Collection housing http:\/\/meetings.contoso.com. This site was created with the default groups of Meetings Visitors, Members and Owners. Then &hellip; Continue reading\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/05\/spweb-associatedmembergroup-returning-incorrect-information\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog of an overweight SharePoint addict\" \/>\n<meta property=\"article:published_time\" content=\"2011-05-25T18:08:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2011-05-25T18:11:40+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/SPWeb.AssociatedMemberGroup-returning-i_10574\/image_thumb.png\" \/>\n<meta name=\"author\" content=\"Cimares\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@cimares\" \/>\n<meta name=\"twitter:site\" content=\"@cimares\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Cimares\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/05\/spweb-associatedmembergroup-returning-incorrect-information\/\",\"url\":\"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/05\/spweb-associatedmembergroup-returning-incorrect-information\/\",\"name\":\"SPWeb.AssociatedMemberGroup returning incorrect information. - Blog of an overweight SharePoint addict\",\"isPartOf\":{\"@id\":\"http:\/\/www.myfatblog.co.uk\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/05\/spweb-associatedmembergroup-returning-incorrect-information\/#primaryimage\"},\"image\":{\"@id\":\"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/05\/spweb-associatedmembergroup-returning-incorrect-information\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/SPWeb.AssociatedMemberGroup-returning-i_10574\/image_thumb.png\",\"datePublished\":\"2011-05-25T18:08:05+00:00\",\"dateModified\":\"2011-05-25T18:11:40+00:00\",\"author\":{\"@id\":\"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/55ae8f6885bb5b8390dad001f3da83c6\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/05\/spweb-associatedmembergroup-returning-incorrect-information\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/05\/spweb-associatedmembergroup-returning-incorrect-information\/#primaryimage\",\"url\":\"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/SPWeb.AssociatedMemberGroup-returning-i_10574\/image_thumb.png\",\"contentUrl\":\"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/SPWeb.AssociatedMemberGroup-returning-i_10574\/image_thumb.png\"},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.myfatblog.co.uk\/#website\",\"url\":\"http:\/\/www.myfatblog.co.uk\/\",\"name\":\"Blog of an overweight SharePoint addict\",\"description\":\"The rantings of a (not so) food obsessed IT consultant!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.myfatblog.co.uk\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/55ae8f6885bb5b8390dad001f3da83c6\",\"name\":\"Cimares\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/About_D057\/TopOfTheWorld.jpg\",\"contentUrl\":\"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/About_D057\/TopOfTheWorld.jpg\",\"caption\":\"Cimares\"},\"sameAs\":[\"http:\/\/www.myfatblog.co.uk\"],\"url\":\"http:\/\/www.myfatblog.co.uk\/index.php\/author\/reginald\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SPWeb.AssociatedMemberGroup returning incorrect information. - Blog of an overweight SharePoint addict","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":"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/05\/spweb-associatedmembergroup-returning-incorrect-information\/","og_locale":"en_US","og_type":"article","og_title":"SPWeb.AssociatedMemberGroup returning incorrect information. - Blog of an overweight SharePoint addict","og_description":"Just recently, I\u00e2\u20ac\u2122ve been working on a solution for a client that wanted to create a meetings portal for a very formal meeting process. The basic breakdown of the site is as follows, A top level Site Collection housing http:\/\/meetings.contoso.com. This site was created with the default groups of Meetings Visitors, Members and Owners. Then &hellip; Continue reading","og_url":"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/05\/spweb-associatedmembergroup-returning-incorrect-information\/","og_site_name":"Blog of an overweight SharePoint addict","article_published_time":"2011-05-25T18:08:05+00:00","article_modified_time":"2011-05-25T18:11:40+00:00","og_image":[{"url":"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/SPWeb.AssociatedMemberGroup-returning-i_10574\/image_thumb.png"}],"author":"Cimares","twitter_card":"summary_large_image","twitter_creator":"@cimares","twitter_site":"@cimares","twitter_misc":{"Written by":"Cimares","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/05\/spweb-associatedmembergroup-returning-incorrect-information\/","url":"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/05\/spweb-associatedmembergroup-returning-incorrect-information\/","name":"SPWeb.AssociatedMemberGroup returning incorrect information. - Blog of an overweight SharePoint addict","isPartOf":{"@id":"http:\/\/www.myfatblog.co.uk\/#website"},"primaryImageOfPage":{"@id":"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/05\/spweb-associatedmembergroup-returning-incorrect-information\/#primaryimage"},"image":{"@id":"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/05\/spweb-associatedmembergroup-returning-incorrect-information\/#primaryimage"},"thumbnailUrl":"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/SPWeb.AssociatedMemberGroup-returning-i_10574\/image_thumb.png","datePublished":"2011-05-25T18:08:05+00:00","dateModified":"2011-05-25T18:11:40+00:00","author":{"@id":"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/55ae8f6885bb5b8390dad001f3da83c6"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.myfatblog.co.uk\/index.php\/2011\/05\/spweb-associatedmembergroup-returning-incorrect-information\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/05\/spweb-associatedmembergroup-returning-incorrect-information\/#primaryimage","url":"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/SPWeb.AssociatedMemberGroup-returning-i_10574\/image_thumb.png","contentUrl":"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/SPWeb.AssociatedMemberGroup-returning-i_10574\/image_thumb.png"},{"@type":"WebSite","@id":"http:\/\/www.myfatblog.co.uk\/#website","url":"http:\/\/www.myfatblog.co.uk\/","name":"Blog of an overweight SharePoint addict","description":"The rantings of a (not so) food obsessed IT consultant!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.myfatblog.co.uk\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/55ae8f6885bb5b8390dad001f3da83c6","name":"Cimares","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/image\/","url":"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/About_D057\/TopOfTheWorld.jpg","contentUrl":"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/About_D057\/TopOfTheWorld.jpg","caption":"Cimares"},"sameAs":["http:\/\/www.myfatblog.co.uk"],"url":"http:\/\/www.myfatblog.co.uk\/index.php\/author\/reginald\/"}]}},"_links":{"self":[{"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/343"}],"collection":[{"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/comments?post=343"}],"version-history":[{"count":7,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/343\/revisions"}],"predecessor-version":[{"id":350,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/343\/revisions\/350"}],"wp:attachment":[{"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/media?parent=343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/categories?post=343"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/tags?post=343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}