Reader Level:
ARTICLE

Programmatically Edit SharePoint Security Group Quick Launch

Posted by Ravish Sindhwani Articles | SharePoint July 05, 2012
In this article you will see how to programmatically edit the SharePoint Security Group Quick Launch.
  • 2
  • 0
  • 6744

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:

SecShr1.jpg

SecShr2.jpg

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"]);
                objSPweb.Update();
            }
        }
/***************************************************************/


In this way we can achieve this requirement.

Hope it will be a help to you!
 

COMMENT USING

Trending up