Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

how i can set the newly created Group as self-owner inside my event reciever

$
0
0

I am working on sharepoint 2013 server , and i have the following event reciever where i am creating new user group inside a sub-site:-

public override void ItemUpdated(SPItemEventProperties properties)
    {

    base.ItemUpdated(properties);

	var currentusername = properties.UserLoginName;
	site.RootWeb.SiteGroups.Add(curItemSiteName, site.RootWeb.SiteUsers[@"domain\" + currentusername], site.RootWeb.SiteUsers[@"domain\" + currentusername], "Some description");
	SPRoleAssignment ra = new SPRoleAssignment(site.RootWeb.SiteGroups[curItemSiteName]);
	ra.RoleDefinitionBindings.Add(site.RootWeb.RoleDefinitions["Contribute"]);
	newSite.RoleAssignments.Add(ra);
	site.RootWeb.RoleAssignments.Add(ra);
        site.RootWeb.Update();
	}

but i m not sure how i can do these 2 modifications:-

1. from the UI i can set these 2 options when creating a new user group:-

so is there a way to do so using my above code?

2. currently i am adding the user who executed the event receiver as the "Group Owner"... but my question is how i can modify my above code to assign the newly create group as the "Group Owner". in other word members of the Group will be the "Group owners"??


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>