• SharePoint中低权限用户通过提升权限创建用户组


    主要代码如下:

     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 }
  • 相关阅读:
    Poj2033
    CodeForces 540
    CodeForces 548
    LeetCode#2 Add Two Numbers
    CodeForces 544A
    POJ 2431Expedition
    HLG1116-选美大赛
    清华学堂 列车调度(Train)
    清华学堂 LightHouse
    清华学堂 Range
  • 原文地址:https://www.cnblogs.com/leolis/p/2313768.html
Copyright © 2020-2023  润新知