主要代码如下:

 1         /// <summary>
2 /// 提升权限创建用户组
3 /// </summary>
4 /// <param name="groupname">用户组的名字</param>
5 public void CreateGroup(string groupname)
6 {
7 SPSecurity.RunWithElevatedPrivileges(delegate()
8 {
9 try
10 {
11 using (SPSite mySite = new SPSite(SPContext.Current.Site.ID))
12 {
13 using (SPWeb myWeb = mySite.OpenWeb())
14 {
15 myWeb.AllowUnsafeUpdates = true;
16 myWeb.SiteGroups.Add(groupname, myWeb.CurrentUser, null, "");
17 myWeb.AllowUnsafeUpdates = false;
18 }
19 }
20 }
21 catch (Exception ex)
22 {
23 //throw custom exception
24 }
25 });
26 }

 

相关文章:

  • 2022-12-23
  • 2022-02-16
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2022-02-18
  • 2021-07-30
猜你喜欢
  • 2022-12-23
  • 2021-12-24
  • 2021-06-20
  • 2021-12-19
  • 2021-09-25
  • 2021-11-22
相关资源
相似解决方案