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
Post a Comment