privatevoid CreateGroup() { // Create new group object GroupInfo newGroup = newGroupInfo(); // Set the properties newGroup.GroupDisplayName = "My new group"; newGroup.GroupName = "MyNewGroup"; newGroup.GroupSiteID = CMSContext.CurrentSiteID; newGroup.GroupDescription = ""; newGroup.GroupApproveMembers = GroupApproveMembersEnum.AnyoneCanJoin; newGroup.GroupAccess = CMS.SiteProvider.SecurityAccessEnum.AllUsers; newGroup.GroupApproved = true; newGroup.GroupApprovedByUserID = CurrentUser.UserID; newGroup.GroupCreatedByUserID = CurrentUser.UserID; newGroup.AllowCreate = SecurityAccessEnum.GroupMembers; newGroup.AllowDelete = SecurityAccessEnum.GroupMembers; newGroup.AllowModify = SecurityAccessEnum.GroupMembers; newGroup.GroupNodeGUID = Guid.Empty; // Save the group GroupInfoProvider.SetGroupInfo(newGroup); }
The following example gets and updates a group.
privatebool GetAndUpdateGroup() {
// Get the group GroupInfo updateGroup = GroupInfoProvider.GetGroupInfo("MyNewGroup", CMSContext.CurrentSiteName);
if (updateGroup != null) { // Update the properties updateGroup.GroupDisplayName = updateGroup.GroupDisplayName.ToLower(); // Save the changes GroupInfoProvider.SetGroupInfo(updateGroup); returntrue; } returnfalse; }
The following example gets and bulk updates groups.
privatebool GetAndBulkUpdateGroups() { // Prepare the parameters string where = "GroupName LIKE N'MyNewGroup%'"; // Get the data DataSet groups = GroupInfoProvider.GetGroups(where, null); if (!DataHelper.DataSourceIsEmpty(groups)) { // Loop through the individual items foreach (DataRow groupDr in groups.Tables[0].Rows) { // Create object from DataRow GroupInfo modifyGroup = newGroupInfo(groupDr);
// Update the properties modifyGroup.GroupDisplayName = modifyGroup.GroupDisplayName.ToUpper();
// Save the changes GroupInfoProvider.SetGroupInfo(modifyGroup); } returntrue; } returnfalse; }
The following example deletes a group.
privatebool DeleteGroup() {
// Get the group GroupInfo deleteGroup = GroupInfoProvider.GetGroupInfo("MyNewGroup", CMSContext.CurrentSiteName);
// Delete the group GroupInfoProvider.DeleteGroupInfo(deleteGroup); return (deleteGroup != null); }