Tuesday, 16 April 2013

Get all the users in the groups

// Get all the users in the groupsSPSite site = new SPSite("http://spsportal:8181");

SPWeb web = site.OpenWeb();web.AllowUnsafeUpdates =
true;
try{
foreach (SPGroup group in web.SiteGroups){
Response.Write(
"<b> " + group.Name + "</b> <br>");
foreach (SPUser user in group.Users){
Response.Write(
"-" + user.Name + "<br>");}
}
}

catch (Exception ex){
Response.Write(ex.Message);
}

No comments:

Post a Comment