Programmatically getting All SharePoint Users


 public void getmyuser(string url, string mygroup)
        {
            try
            {
                using (SPSite osite = new SPSite(url))
                {
                    using (SPWeb oweb = osite.OpenWeb())
                    {
                        SPGroupCollection ogrpcol = oweb.Groups;
                        SPUserCollection ousrcol = oweb.AllUsers;
                        foreach (SPGroup ogrp in ogrpcol)
                        {
                            if (ogrp.Name == mygroup)
                            {
                                foreach (SPUser ousr in ousrcol)
                                {
                                    ArrayList.Add(ousr.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