SPRoleAssignment Crazy Caviats

Posted by MOSSLover on Geeks with Blogs See other posts from Geeks with Blogs or by MOSSLover
Published on Fri, 05 Mar 2010 19:11:14 GMT Indexed on 2010/03/07 23:28 UTC
Read the original article Hit count: 462

Filed under:

I’m not sure if this bug exists on any other environment, but here are a few issues I ran into when trying to use SPRoleAssignment and SPGroup:

  • When trying to use Web.Groups[“GroupName”] it basically told me the group did not exist, so I had to change the code to use Web.SiteGroups[“GroupName”].
  • I could not add the Role Assignment to the Web and run a Web.Update() without adding an additional Web.AllowUnsafeUpdates= true; , however on my virtual machine I could do a Web.Update() without the extra piece of code.  I kept receiving an error in my browser stating that I should hit the back button and update my permissions.

So after fixing those two issues I was able to copy the permissions from a page item into a Site for my migration.  Hopefully, one of you can learn from my error messages if you have any issues in the future.

Technorati Tags: ,,

© Geeks with Blogs or respective owner