private void getGroup()
{
SPSite oCurrentSite = new SPSite(SPContext.Current.Web.Url);
SPWeb web = oCurrentSite.OpenWeb();
SPUser user = web.EnsureUser(SPContext.Current.Web.CurrentUser.Name.ToString());
SPGroupCollection groups = user.Groups;
foreach (SPGroup group in SPContext.Current.Web.Groups)
{
foreach (SPUser user1 in group.Users)
{
if (user1.Name == user.Name)
{
String strGroupName = group.Name.ToString();
ViewState["GroupName"] = strGroupName;
}
}
}
}
No comments:
Post a Comment