zoukankan      html  css  js  c++  java
  • 创建用户组

    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;
                            }
                        }
                    });

  • 相关阅读:
    正则表达式
    70. 爬楼梯
    最大子序和
    动态规划
    中序遍历
    两数相加基础
    保证一个线程最后执行或者最先执行CyclicBarrier
    保证一个线程最后执行使用CountDownLatch
    两个线程交替执行
    单列模式double check的问题
  • 原文地址:https://www.cnblogs.com/hqbird/p/2044325.html
Copyright © 2011-2022 走看看