Programmatically getting All SharePoint groups


public void getAllGroups(string SiteUrl)
        {
            try
            {
                using (SPSite osite = new SPSite(SiteUrl))
                {
                    SPWebCollection owebcoll = osite.AllWebs;
                    foreach (SPWeb oweb in owebcoll)
                    {                      
                        foreach (SPGroup ogrp in oweb.Groups)
                        {
                            arrGroups.Add(ogrp.Name);
                        }
                     
                    }
                   
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);  
            }
         

Comments

Popular posts from this blog

IRM and the Object Model

This content database has a schema version which is not supported in this farm

Activate and Deactivate Feature through PowerShell