SPWeb.Groups vs SPWeb.AssociatedGroups
Asked Answered
S

2

11

I've seen three types of group properties for an SPWeb object - Groups, SiteGroups, AssociatedGroups.

I understand that SiteGroups will fetch all the groups in the current site collection. But what is the difference between Groups and AssociatedGroups. MSDN definition says that Groups will get all the 'cross-site'(!) groups for that web site. AssociatedGroups are fairly easily to understand just from the very name.

So what does Groups return? Can somebody explain me with an example?

Stringboard answered 19/1, 2011 at 12:46 Comment(0)
E
15

Groups return all groups which have security roles assigned to the current site.

AssociatedGroups return all groups visible in the left menu of the People and Group page. Those groups may not have access to the current site (if the security settings do not inherit from parent site). In this case, some of them will not be listed in the Groups property.

To view the difference, in a subsite, create a new group without giving any permission. The group will be visible in the AssociatedGroups and Left menu, but will not be listed in Groups or Site Permissions page.

Exegetic answered 19/1, 2011 at 13:8 Comment(0)
M
-1

I believe msdn has the answer

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.sitegroups.aspx

Gets a collection that contains all the groups in the site collection.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.groups.aspx

Gets a collection that contains all the groups for the website. The following code example uses the Groups property to return the collection of groups for a specified site in the current site collection.

Which means, the SPGroup has been used in (ie assigned a permission in) the SPWeb somewhere.

Minneapolis answered 19/1, 2011 at 12:57 Comment(1)
-1 - I've clearly asked Groups vs AssociatedGroups. Not SiteGroups vs Groups.Stringboard

© 2022 - 2024 — McMap. All rights reserved.