Tyler Holmes has an old post on his blog that I felt is with worth mentioning as I faced this problem on a recent project and it is not the most intuitive behavior (but with SharePoint, what is?).
SPWeb.Groups vs. SPWeb.SiteGroups [Tyler Holmes]
You can learn a lot in a minute
Tyler Holmes has an old post on his blog that I felt is with worth mentioning as I faced this problem on a recent project and it is not the most intuitive behavior (but with SharePoint, what is?).
SPWeb.Groups vs. SPWeb.SiteGroups [Tyler Holmes]
The following is a method to create new cross-site groups in SharePoint 2007/WSS 3.0. Along with creating the group, users are also added to the group based on selections from a PeopleEditor control (better known as the People Picker).
private enum GroupType
{
Owners,
Members,
Visitors
}
public SPWeb CurrentWeb
{
get { return SPContext.GetContext(HttpContext.Current).Web; }
}
private void CreateAndPopulateGroup(string groupName, GroupType groupType, bool createNewGroup)
{
// [...]
To add a Windows Active Directory Security Group to a SharePoint 2007 or WSS 3.0 site, do the following:
SPContext.GetContext(HttpContext.Current).Web.AllUsers.Add("domain\\Group", "", "", "domain\\Group" );
To add your group to an existing site role (Full Control, Contribute, Read, etc.), use the following:
SPWeb cWeb = SPContext.GetContext(HttpContext.Current).Web;
SPUser user = cWeb .AllUsers["domain\\Group"];
SPGroup grouptoadd = cWeb .Groups["Full Control"];
grouptoadd.AddUser(user);
To create a new SPWeb (a new site or workspace) and add it to the navigation (Top and QuickLaunch), you can use the following snippet:
SPWeb newWeb;
newWeb = SPContext.GetContext(HttpContext.Current).Web.Webs.Add(strURL, //URL ("foo" would generate example.com/foo)
strTitle, //Title
strDescription, //Description
(uint)1033, // English
strTemplate, // Template type
bUseUnique, // Use unique permissions?
false); // Convert existing web?
newWeb.Navigation.UseShared = (someCondition) ? true : false;
newWeb.Update();
if (newWeb.Navigation.UseShared)
{
Microsoft.SharePoint.Navigation.SPNavigationNode [...]
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Jul | ||||||
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |