I’ve been in the trenches updating DeliverPoint to work with Windows SharePoint Services 3.0/Microsoft Office SharePoint Server 2007 for the past 3 months and thought I’d take a moment to start blogging some issues I’ve found along the way yet have not had the time to post yet.
Apparently SPWeb.HasUniqueRoleDefintions does not always report accurately.
From the SDK as of 04-10-2007:
“Gets a Boolean value that indicates whether the role definitions are uniquely defined for this Web site or inherited from a parent Web site.“
But here’s the problem.
Regardless if HasUnqiueRoleDefinitions is true or false, when you access the ParentWeb property of the SPRoleDefinition you get from the SPWeb.RoleDefinitions collection, ParentWeb always returns a reference to the same web the collection is being derived from. I.e., it never points to any other web.
So if by chance you were working with a SPRoleDefinition for a SPWeb where HasUniqueRoleDefinitions was false, and you accessed SPRoleDefinition.ParentWeb, you would in fact get that web. SPRoleDefinition.ParentWeb always refers to the web the collection was derived from. Therefore from a reference to SPRoleDefinition.ParentWeb, I could not enumerate the proper RoleDefinition collection from ParentWeb.RoleDefinitions. It’s possible that said SPRoleDefinition doesn’t even belong in that collection.
This means one of three different possibilities
1) Role Definitions are truly uniquely defined at every web (Just like the old V2 “Group”….That’s really what they are), and HasUniqueRoleDefinitions is something that was an “Idea” but was never fleshed out, because the concept of Role Definition inheritance never was fully fleshed out, or
2) I’ve misread the purpose of this property, and relating it to the RoleDefinition collection for the web, i.e…Just because HasUniqueRoleDefinitions might be True, does not mean that you can access the SPWeb.RoleDefinitions to get to those unique Role Definitions at that web.
3) SPWeb.hasUniqueRoleDefintions is flat out busted.
Regardless, I can’t rely on it, and I can’t wait for a hotfix to be released and take a dependency on the hotfix or a later service pack…So, I’ve “worked around” the problem :).