SharePoint Utility to fetch active users and groups of the sharepoint site

This utility fetches all the sharepoint group and members of the sharepoint site with permissions.

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

namespace ConsoleApplication1
    class Program
        static void Main(string[] args)
            SPSite siteCollection = new SPSite("Site URL");
            SPWeb site = siteCollection.OpenWeb();

            foreach (SPGroup group in site.Groups)
                //will give user group name            

                foreach (SPUser u in group.Users)
                    Console.Write(u.Name + "("  + u.Email + ")" + "\n");
                    //will give users in group, you can then grab the roles of the user



By Devil Scorpio   Popularity  (2565 Views)