• 创建用户组


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

  • 相关阅读:
    [可能没有默认的字体]Warning: imagettfbbox() [function.imagettfbbox]: Invalid font filename...
    <yii 框架学习> yii 框架改为中文提示
    Yii 语言设置 中文提示信息
    yii新手在实例化models(controller调用models实化化)php warning错误
    yii CFormModel中的rules验证机制
    神舟优雅系列和神舟精盾系列哪个好?
    response.sendRedirect跳转 jsp:forward跳转
    jsp post/get中接处理
    jsp动作之 forward
    JDK eclipse selenium的安装以及环境变量的配置
  • 原文地址:https://www.cnblogs.com/hqbird/p/2044325.html
Copyright © 2020-2023  润新知