Reader Level:

Programmatically Edit SharePoint Security Group Quick Launch

By Ravish Sindhwani on Jul 05 2012
In this article you will see how to programmatically edit the SharePoint Security Group Quick Launch.
    • Like
    • Love It
    • Awesome
    • Interesting
    • It's Okay
    • Thumbs Down
  • 13.8k
  • 0

We often have a requirement such as to create a SharePoint Group and at the same time we need to add the name of this newly created security group in the Security Group quick launch.

This can be done using the SharePoint User Interface like this:



Likewise we can edit the SharePoint quick launch and add or remove the Security Groups from it.

What if we have a requirement to edit it programmatically?

Suppose we have a requirement to create a SharePoint Group programmatically and at the same time this newly created SharePoint Group needs to be added to the Security Group Quick Launch and removed from some other groups.

The following is the code snippet which can be used to edit the Security Group Quick Launch.

objSPweb.AssociatedGroups.Add() and objSPweb.AssociatedGroups.Remove() are the two methods which are used to edit the Security Group Quick launch.

        ///Edit Group Quick Launch
        using (SPSite objSPSite = new SPSite(SPContext.Current.Web.Url))
            using (SPWeb objSPweb = objSPSite.OpenWeb())
                objSPweb.AllowUnsafeUpdates = true;
                objSPweb.AssociatedGroups.Add(SPContext.Current.Web.Groups["Test Members"]);

In this way we can achieve this requirement.

Hope it will be a help to you!