SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(curSite.ID))
{
using (SPWeb web = site.OpenWeb(curWeb.ID))
{
site.AllowUnsafeUpdates = true;
web.AllowUnsafeUpdates = true;
SPMember spUserMember = null;
SPUser spUser = web.CurrentUser;
//spUserMember = web.SiteAdministrators[0];
spUserMember = curWeb.CurrentUser;
web.SiteGroups.Add(strUserGroup, spUserMember, null, description);
SPList spList = web.Lists["用户信息列表"];
SPGroup spgroup = web.SiteGroups[strUserGroup];
SPListItem groupItem = spList.GetItemById(spgroup.ID);
groupItem["Create"] = (object)curWeb.CurrentUser.LoginName;
groupItem["Modifier"] = (object)curWeb.CurrentUser.LoginName;
groupItem["IsGroup"] = (object)"职责";
groupItem["IsEnable"] = (object)ddlIsEnable.SelectedValue;
groupItem.Update();
site.AllowUnsafeUpdates = false;
web.AllowUnsafeUpdates = false;
}
}
});