Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8274859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:52:37+00:00 2026-06-08T07:52:37+00:00

As per this entry: Cloning a sharepoint rolegroup I’m trying to create a console

  • 0

As per this entry: Cloning a sharepoint rolegroup I’m trying to create a console application to copy a SharePoint group, including its permissions.

Based on the answer from Tjassens I’ve reached the following:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;  

namespace REGroupCopy
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite spSite = new SPSite("http://dev"))
            {
                using (SPWeb spWeb = spSite.RootWeb)
                {
                    // first we find the group that we want to clone
                    SPGroup group = spWeb.Groups["Test Group"];

                    // then we use this retreived group to get the roleassignments on the SPWeb object
                    SPRoleAssignment ass = spWeb.RoleAssignments.GetAssignmentByPrincipal(group);

                    string groupName = "Test Group 2"; // group to create
                    string groupDescription = "Group created by REGroupCopy";
                    string user = "michael";

                    spWeb.SiteGroups.Add(groupName, user, user, groupDescription);
                    SPGroup newGroup = spWeb.SiteGroups[groupName];
                    SPRoleAssignment roleAssignment = new SPRoleAssignment(newGroup);

                    //add role to web
                    spWeb.RoleAssignments.Add(roleAssignment);
                    spWeb.Update();
                }
            }         
        }
    }
}

Unfortunately I don’t think I’m understanding everything correctly. Specifically, I think these lines are incorrect, but I’m unsure what they should be:

                string groupName = "Test Group 2"; // group to create
                string groupDescription = "Group created by REGroupCopy";
                string user = "michael";

                spWeb.SiteGroups.Add(groupName, user, user, groupDescription);

I don’t necessarily need somebody to come along and fix this for me (after all ,this is a learning exercise). Instead, could you please help me to understand where my thought process is falling down and what I need to learn to rectify this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T07:52:38+00:00Added an answer on June 8, 2026 at 7:52 am

    You have found the correct problem with your code. When you call the following method:

    spWeb.SiteGroups.Add(groupName, user, user, groupDescription); 
    

    you forgot that the user should not be a string but an actual SPUser object. If you get the SPUser object you should be able to add the new group to the SPWeb/SPSite.

    you can get the user object by using for instance:

    SPUser spUser = spWeb.EnsureUser(loginName);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As per this article, every cluster has its own storage. A cluster hosts millions
I'm trying to build a Synergy AutoStart script as per this article , the
I'm creating a data-entry application where users are allowed to create the entry schema.
I am trying to sort an associative array which has multiple vales per entry.
Per this question (see comments near the bottom), I was wondering if anyone knows
As per this article : If you try and lock a non-recursive mutex twice
As per this MSDN article: W3C Extended Log File Format (IIS 6.0) It says
I am having the same issues as per this question: WCF not deserializing JSON
I am putting a label on a UIToolbar (per this tip: Adding a UILabel
I've started to become a Good Citizen, as per this question here: Domain compatibility:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.