当前位置: 首页>>代码示例>>C#>>正文


C# RoleController.AddUserRole方法代码示例

本文整理汇总了C#中DotNetNuke.Security.Roles.RoleController.AddUserRole方法的典型用法代码示例。如果您正苦于以下问题:C# RoleController.AddUserRole方法的具体用法?C# RoleController.AddUserRole怎么用?C# RoleController.AddUserRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DotNetNuke.Security.Roles.RoleController的用法示例。


在下文中一共展示了RoleController.AddUserRole方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddClientEditorRole

 public void AddClientEditorRole()
 {
     if (_userInfo != null)
     {
         if (!_userInfo.IsInRole(StoreSettings.ClientEditorRole))
         {
             var rc = new DotNetNuke.Security.Roles.RoleController();
             var ri = rc.GetRoleByName(PortalId, StoreSettings.ClientEditorRole);
             if (ri != null) rc.AddUserRole(PortalId, _userInfo.UserID, ri.RoleID, Null.NullDate, Null.NullDate);
             if (StoreSettings.Current.Get("sendclientroleemail") == "True") NBrightBuyUtils.SendEmail(_userInfo.Email, "addclientrole.html", _clientInfo, "", "", _userInfo.Profile.PreferredLocale);
         }
     }
 }
开发者ID:DNNMonster,项目名称:NBrightBuy,代码行数:13,代码来源:ClientData.cs

示例2: ParseTemplate

        /// <summary>
        /// Processess a template file for the new portal. This method will be called twice: for the portal template and for the admin template
        /// </summary>
        /// <param name="PortalId">PortalId of the new portal</param>
        /// <param name="TemplatePath">Path for the folder where templates are stored</param>
        /// <param name="TemplateFile">Template file to process</param>
        /// <param name="AdministratorId">UserId for the portal administrator. This is used to assign roles to this user</param>
        /// <param name="mergeTabs">Flag to determine whether Module content is merged.</param>
        /// <param name="IsNewPortal">Flag to determine is the template is applied to an existing portal or a new one.</param>
        /// <remarks>
        /// The roles and settings nodes will only be processed on the portal template file.
        /// </remarks>
        /// <history>
        /// 	[VMasanas]	27/08/2004	Created
        /// </history>
        public void ParseTemplate( int PortalId, string TemplatePath, string TemplateFile, int AdministratorId, PortalTemplateModuleAction mergeTabs, bool IsNewPortal )
        {
            XmlDocument xmlDoc = new XmlDocument();
            XmlNode node = null;
            int AdministratorRoleId = -1;
            int RegisteredRoleId = -1;
            int SubscriberRoleId = -1;
            RoleController objrole = new RoleController();
            bool isAdminTemplate = false;

            isAdminTemplate = ( TemplateFile == "admin.template" );

            // open the XML file
            try
            {
                xmlDoc.Load( TemplatePath + TemplateFile );
            }
            catch // error
            {
                // 
            }

            // settings, roles, folders and files can only be specified in portal templates, will be ignored on the admin template
            if( !isAdminTemplate )
            {
                // parse roles if available
                node = xmlDoc.SelectSingleNode( "//portal/roles" );
                if( node != null )
                {
                    ParseRoles( node, PortalId, AdministratorId, ref AdministratorRoleId, ref RegisteredRoleId, ref SubscriberRoleId );
                }

                // create required roles if not already created
                if( AdministratorRoleId == -1 )
                {
                    AdministratorRoleId = CreateRole( PortalId, "Administrators", "Portal Administrators", 0F, 0, "M", 0F, 0, "N", false, false );
                }
                if( RegisteredRoleId == -1 )
                {
                    RegisteredRoleId = CreateRole( PortalId, "Registered Users", "Registered Users", 0F, 0, "M", 0F, 0, "N", false, true );
                }
                if( SubscriberRoleId == -1 )
                {
                    SubscriberRoleId = CreateRole( PortalId, "Subscribers", "A public role for portal subscriptions", 0F, 0, "M", 0F, 0, "N", true, true );
                }

                objrole.AddUserRole( PortalId, AdministratorId, AdministratorRoleId, Null.NullDate, Null.NullDate );
                objrole.AddUserRole( PortalId, AdministratorId, RegisteredRoleId, Null.NullDate, Null.NullDate );
                objrole.AddUserRole( PortalId, AdministratorId, SubscriberRoleId, Null.NullDate, Null.NullDate );

                // parse portal folders
                node = xmlDoc.SelectSingleNode( "//portal/folders" );
                if( node != null )
                {
                    ParseFolders( node, PortalId );
                }
                // force creation of root folder if not present on template
                FolderController objController = new FolderController();
                if( objController.GetFolder( PortalId, "" ) == null )
                {
                    int folderid = objController.AddFolder( PortalId, "", (int)FolderController.StorageLocationTypes.InsecureFileSystem, true, false );
                    PermissionController objPermissionController = new PermissionController();
                    ArrayList arr = objPermissionController.GetPermissionByCodeAndKey( "SYSTEM_FOLDER", "" );
                    foreach( PermissionInfo objpermission in arr )
                    {
                        FileSystemUtils.SetFolderPermission( PortalId, folderid, objpermission.PermissionID, AdministratorRoleId, "" );
                        if( objpermission.PermissionKey == "READ" )
                        {
                            // add READ permissions to the All Users Role
                            FileSystemUtils.SetFolderPermission( PortalId, folderid, objpermission.PermissionID, int.Parse( Globals.glbRoleAllUsers ), "" );
                        }
                    }
                }

                // parse portal settings if available only for new portals
                node = xmlDoc.SelectSingleNode( "//portal/settings" );
                if( node != null & IsNewPortal )
                {
                    ParsePortalSettings( node, PortalId );
                }

                // update portal setup
                PortalInfo objportal = null;
                objportal = GetPortal( PortalId );
                UpdatePortalSetup( PortalId, AdministratorId, AdministratorRoleId, RegisteredRoleId, objportal.SplashTabId, objportal.HomeTabId, objportal.LoginTabId, objportal.UserTabId, objportal.AdminTabId );
//.........这里部分代码省略.........
开发者ID:huayang912,项目名称:cs-dotnetnuke,代码行数:101,代码来源:PortalController.cs

示例3: CreateStaffMember

    public static AP_StaffBroker_Staff CreateStaffMember(int PortalId, DotNetNuke.Entities.Users.UserInfo User1in, string SpouseName, DateTime SpouseDOB, short staffTypeIn = 1)
    {
        DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController();
        if (rc.GetRoleByName(PortalId, "Staff") == null)
        {
            DotNetNuke.Security.Roles.RoleInfo insert = new DotNetNuke.Security.Roles.RoleInfo();
            insert.Description = "Staff Members";
            insert.RoleName = "Staff";
            insert.AutoAssignment = false;
            insert.IsPublic = false;
            insert.RoleGroupID = -1;
            insert.PortalID = PortalId;
            rc.AddRole(insert);
        }

        rc.AddUserRole(PortalId, User1in.UserID, rc.GetRoleByName(PortalId, "Staff").RoleID, DateTime.MaxValue);

        StaffBrokerDataContext d = new StaffBrokerDataContext();
        var searchStaff = from c in d.AP_StaffBroker_Staffs where c.Active && (c.UserId1 == User1in.UserID || c.UserId2 == User1in.UserID) select c;
        if (searchStaff.Count() > 0)
            return searchStaff.First();
        //Create Married to Non-Staff
        AP_StaffBroker_Staff rtn = new AP_StaffBroker_Staff();
        rtn.UserId1 = User1in.UserID;
        rtn.UserId2 = -1;
        rtn.DisplayName = User1in.FirstName + " " + User1in.LastName;

        rtn.StaffTypeId = staffTypeIn;
        rtn.CostCenter = "";
        rtn.PortalId = PortalId;
        rtn.Active = true;
        d.AP_StaffBroker_Staffs.InsertOnSubmit(rtn);
        d.SubmitChanges();
        //Now add Spouse data
        AddProfileValue(PortalId, rtn.StaffId, "SpouseDOB", SpouseDOB.ToShortDateString());
        AddProfileValue(PortalId, rtn.StaffId, "SpouseName", SpouseName);

        return rtn;
    }
开发者ID:GlobalTechnology,项目名称:OpsInABox,代码行数:39,代码来源:StaffBrokerFunctions.cs

示例4: Create_Click

        private void Create_Click(object sender, EventArgs e)
        {
            RoleController roleController = new RoleController();
            Security.PortalSecurity ps = new Security.PortalSecurity();
            txtGroupName.Text = ps.InputFilter(txtGroupName.Text, Security.PortalSecurity.FilterFlag.NoScripting);
            txtGroupName.Text = ps.InputFilter(txtGroupName.Text, Security.PortalSecurity.FilterFlag.NoMarkup);

            txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoScripting);
            txtDescription.Text = ps.InputFilter(txtDescription.Text, Security.PortalSecurity.FilterFlag.NoMarkup);
            if (roleController.GetRoleByName(PortalId, txtGroupName.Text) != null)
            {
                reqGroupName.Visible = true;
                return;
            }
            List<RoleInfo> modRoles = new List<RoleInfo>();
            foreach (ModulePermissionInfo modulePermissionInfo in ModulePermissionController.GetModulePermissions(ModuleId, TabId))
            {
                if (modulePermissionInfo.PermissionKey == "MODGROUP" && modulePermissionInfo.AllowAccess)
                {
                    modRoles.Add(roleController.GetRole(modulePermissionInfo.RoleID, PortalId));
                }
            }
            RoleInfo roleInfo = new RoleInfo()
            {
                PortalID = PortalId,
                RoleName = txtGroupName.Text,
                Description = txtDescription.Text,
                SecurityMode = SecurityMode.SocialGroup,
                Status = RoleStatus.Approved,
                IsPublic = rdAccessTypePublic.Checked
            };
            var userRoleStatus = RoleStatus.Pending;
            if (GroupModerationEnabled)
            {
                roleInfo.Status = RoleStatus.Pending;
                userRoleStatus = RoleStatus.Pending;
            }
            else
            {
                userRoleStatus = RoleStatus.Approved;
            }

            var objModulePermissions = new ModulePermissionCollection(CBO.FillCollection(DataProvider.Instance().GetModulePermissionsByModuleID(ModuleId, -1), typeof(ModulePermissionInfo)));
            if (ModulePermissionController.HasModulePermission(objModulePermissions, "MODGROUP"))
            {
                roleInfo.Status = RoleStatus.Approved;
                userRoleStatus = RoleStatus.Approved;
            }
            roleInfo.RoleGroupID = DefaultRoleGroupId;

            roleInfo.RoleID = roleController.AddRole(roleInfo);
            roleInfo = roleController.GetRole(roleInfo.RoleID, PortalId);
            roleInfo.Settings.Add("URL", Globals.NavigateURL(GroupViewTabId, "", new String[] { "groupid=" + roleInfo.RoleID.ToString() }));
            roleInfo.Settings.Add("GroupCreatorName", UserInfo.DisplayName);
            roleInfo.Settings.Add("ReviewMembers", chkMemberApproved.Checked.ToString());

            TestableRoleController.Instance.UpdateRoleSettings(roleInfo, true);
            if (inpFile.PostedFile.ContentLength > 0)
            {
                IFileManager _fileManager = FileManager.Instance;
                IFolderManager _folderManager = FolderManager.Instance;
                var rootFolderPath = PathUtils.Instance.FormatFolderPath(PortalSettings.HomeDirectory);

                IFolderInfo groupFolder = _folderManager.GetFolder(PortalSettings.PortalId, "Groups/" + roleInfo.RoleID);
                if (groupFolder == null)
                {
                    groupFolder = _folderManager.AddFolder(PortalSettings.PortalId, "Groups/" + roleInfo.RoleID);
                }
                if (groupFolder != null)
                {
                    var fileName = Path.GetFileName(inpFile.PostedFile.FileName);
                    var fileInfo = _fileManager.AddFile(groupFolder, fileName, inpFile.PostedFile.InputStream, true);
                    roleInfo.IconFile = "FileID=" + fileInfo.FileId;
                    roleController.UpdateRole(roleInfo);
                }
            }

            Components.Notifications notifications = new Components.Notifications();


            roleController.AddUserRole(PortalId, UserId, roleInfo.RoleID, userRoleStatus, true, Null.NullDate, Null.NullDate);
            if (roleInfo.Status == RoleStatus.Pending)
            {
                //Send notification to Group Moderators to approve/reject group.
                notifications.AddGroupNotification(Constants.GroupPendingNotification, GroupViewTabId, ModuleId, roleInfo, UserInfo, modRoles);
            }
            else
            {
                //Send notification to Group Moderators informing of new group.
                notifications.AddGroupNotification(Constants.GroupCreatedNotification, GroupViewTabId, ModuleId, roleInfo, UserInfo, modRoles);

                //Add entry to journal.
                GroupUtilities.CreateJournalEntry(roleInfo, UserInfo);
            }

            Response.Redirect(Globals.NavigateURL(GroupViewTabId, "", new String[] { "groupid=" + roleInfo.RoleID.ToString() }));
        }
开发者ID:biganth,项目名称:Curt,代码行数:97,代码来源:Create.ascx.cs

示例5: CreateDefaultPortalRoles

        private static void CreateDefaultPortalRoles(int portalId, int administratorId, ref int administratorRoleId, ref int registeredRoleId, ref int subscriberRoleId, int unverifiedRoleId)
        {
            var controller = new RoleController();

            //create required roles if not already created
            if (administratorRoleId == -1)
            {
                administratorRoleId = CreateRole(portalId, "Administrators", "Administrators of this Website", 0, 0, "M", 0, 0, "N", false, false);
            }
            if (registeredRoleId == -1)
            {
                registeredRoleId = CreateRole(portalId, "Registered Users", "Registered Users", 0, 0, "M", 0, 0, "N", false, true);
            }
            if (subscriberRoleId == -1)
            {
                subscriberRoleId = CreateRole(portalId, "Subscribers", "A public role for site subscriptions", 0, 0, "M", 0, 0, "N", true, true);
            }
            if (unverifiedRoleId == -1)
            {
                CreateRole(portalId, "Unverified Users", "Unverified Users", 0, 0, "M", 0, 0, "N", false, false);
            }
            controller.AddUserRole(portalId, administratorId, administratorRoleId, Null.NullDate, Null.NullDate);
            controller.AddUserRole(portalId, administratorId, registeredRoleId, Null.NullDate, Null.NullDate);
            controller.AddUserRole(portalId, administratorId, subscriberRoleId, Null.NullDate, Null.NullDate);
        }
开发者ID:rrsc,项目名称:Dnn.Platform,代码行数:25,代码来源:PortalController.cs

示例6: btnSynStu_Click

        const int TimeOut = 3600; // 1 hour

        #endregion Fields

        #region Methods

        protected void btnSynStu_Click(object sender, EventArgs e)
        {
            // Prepare for longtime jobs
            Server.ScriptTimeout = TimeOut;

            // Get list of all students
            var allStus = SqlHelper.ExecuteDataset(Config.GetConnectionString(), CommandType.Text, "SELECT StuId, StuNm, BDay, Email FROM Student").Tables[0];
            int total = allStus.Rows.Count;
            lblStuTotal.Text = total.ToString();
            // Count all students
            var allStuIds = (from r in allStus.Rows.Cast<DataRow>()
                             select (string)r["StuId"]).ToList();
            // Get StuId with profile
            var allStuInfos = (from r in allStus.Rows.Cast<DataRow>()
                               select r).ToDictionary(
                               r => (string)r["StuId"],
                               r => new
                               {
                                   Name = r["StuNm"] == DBNull.Value ? null : (string)r["StuNm"],
                                   BDay = r["BDay"] == DBNull.Value ? null : (DateTime?)r["BDay"],
                                   Email = r["Email"] == DBNull.Value ? null : (string)r["Email"],
                               });

            // Count registered students
            var roleCtlr = new RoleController();
            var roleId = roleCtlr.GetRoleByName(PortalId, "Student").RoleID;
            var regStus = SqlHelper.ExecuteDataset(Config.GetConnectionString(), CommandType.Text,
                string.Format("SELECT Users.Username FROM UserRoles INNER JOIN Users ON UserRoles.UserID = Users.UserID WHERE (UserRoles.RoleID = {0})", roleId)).Tables[0]; ;
            var regStuIds = (from u in regStus.Rows.Cast<DataRow>()
                             select (string)u["Username"]).ToList();

            // Count free students
            var freeStuIds = allStuIds.Except(regStuIds).ToArray();
            foreach (var stuid in freeStuIds)
            {
                var userinfo = new UserInfo
                {
                    PortalID = PortalId,
                    Username = stuid,
                    DisplayName = allStuInfos[stuid].Name,
                    FullName = allStuInfos[stuid].Name,
                    Email = allStuInfos[stuid].Email,
                };
                if (allStuInfos[stuid].BDay.HasValue)
                    userinfo.Membership.Password = string.Format("{0}{1}", stuid, allStuInfos[stuid].BDay.Value.Year % 100);
                else
                    userinfo.Membership.Password = stuid;
                var status = UserController.CreateUser(ref userinfo);
                if (status == UserCreateStatus.UserAlreadyRegistered)
                {
                    var userid = UserController.GetUserByName(PortalId, stuid).UserID;
                    // Add user to Student role
                    roleCtlr.AddUserRole(PortalId, userid, roleId, DateTime.MinValue);
                    regStuIds.Add(stuid);
                }
                else if (status == UserCreateStatus.Success)
                {
                    // Add user to Student role
                    roleCtlr.AddUserRole(PortalId, userinfo.UserID, roleId, DateTime.MaxValue);
                    regStuIds.Add(stuid);
                }
            }

            int no_reg = regStuIds.Count();
            lblNoRegStu.Text = no_reg.ToString();
            int no_free = total - no_reg;
            lblNoFreeStu.Text = no_free.ToString();
            freeStuIds = allStuIds.Except(regStuIds).ToArray();
            lblFreeStus.Text = string.Join(", ", freeStuIds);
        }
开发者ID:hoaian89,项目名称:DAA,代码行数:76,代码来源:StudentSyn.ascx.cs

示例7: AutoAssignUsersToRoles

        private static void AutoAssignUsersToRoles(UserInfo user, int portalId)
        {
            var roleController = new RoleController();
            var portalController = new PortalController();
            var thisPortal = portalController.GetPortal(portalId);

            if (IsMemberOfPortalGroup(portalId))
            {
                foreach (var portal in PortalGroupController.Instance.GetPortalsByGroup(thisPortal.PortalGroupID))
                {
                    if (!user.Membership.Approved && portal.UserRegistration == (int)Globals.PortalRegistrationType.VerifiedRegistration)
                    {
                        var role = TestableRoleController.Instance.GetRole(portal.PortalID, r => r.RoleName == "Unverified Users");
                        roleController.AddUserRole(portal.PortalID, user.UserID, role.RoleID, Null.NullDate, Null.NullDate);
                    }
                    else
                    {
                        AutoAssignUsersToPortalRoles(user, portal.PortalID);
                    }
                }
            }
            else
            {
                if (!user.Membership.Approved && thisPortal.UserRegistration == (int)Globals.PortalRegistrationType.VerifiedRegistration)
                {
                    var role = TestableRoleController.Instance.GetRole(portalId, r => r.RoleName == "Unverified Users");
                    roleController.AddUserRole(portalId, user.UserID, role.RoleID, Null.NullDate, Null.NullDate);
                }
                else
                {
                    AutoAssignUsersToPortalRoles(user, portalId);
                }
            }
        }
开发者ID:uXchange,项目名称:Dnn.Platform,代码行数:34,代码来源:UserController.cs

示例8: CreateUser

        /// <summary>
        /// Creates a new User in the Data Store
        /// </summary>
        /// <remarks></remarks>
        /// <param name="objUser">The userInfo object to persist to the Database</param>
        /// <returns>The Created status ot the User</returns>
        public static UserCreateStatus CreateUser(ref UserInfo objUser)
        {
            //Create the User
            UserCreateStatus createStatus = memberProvider.CreateUser(ref objUser);

            if (createStatus == UserCreateStatus.Success && !objUser.IsSuperUser)
            {
                RoleController objRoles = new RoleController();

                // autoassign user to portal roles
                ArrayList arrRoles = objRoles.GetPortalRoles(objUser.PortalID);
                
                for (int i = 0; i < arrRoles.Count; i++)
                {
                    RoleInfo objRole = (RoleInfo)arrRoles[i];
                    if (objRole.AutoAssignment)
                    {
                        objRoles.AddUserRole(objUser.PortalID, objUser.UserID, objRole.RoleID, Null.NullDate, Null.NullDate);
                    }
                }
            }

            return createStatus;
        }
开发者ID:huayang912,项目名称:cs-dotnetnuke,代码行数:30,代码来源:UserController.cs

示例9: CreateDNNUser

        private UserCreateStatus CreateDNNUser(UserInfo user)
        {
            user.Membership.Password = UserController.GeneratePassword(12).ToString();
            user.PortalID = PortalId;
            user.IsSuperUser = false;

            UserCreateStatus createStatus = UserCreateStatus.AddUser;

            //Create the User
            createStatus = UserController.CreateUser(ref user);

            if (createStatus == UserCreateStatus.Success)
            {
                RoleController objRoles = new RoleController();

                List<int> rolesList = new List<int>();

                foreach (int roleID in rolesList)
                {
                    objRoles.AddUserRole(user.PortalID, user.UserID, roleID, Null.NullDate, Null.NullDate);
                }
            }

            return createStatus;
        }
开发者ID:assadvirgo,项目名称:Aspose_Cells_NET,代码行数:25,代码来源:View.ascx.cs

示例10: Roles_AddRemove

        public HttpResponseMessage Roles_AddRemove(int userid, string role, string mode)
        {

            int v_Current_Portal_ID = this.ActiveModule.PortalID;

            //Getting user info
            DotNetNuke.Entities.Users.UserInfo v_UserInfo = DotNetNuke.Entities.Users.UserController.GetUserById(v_Current_Portal_ID, userid);

            if (v_UserInfo != null)
            {

                RoleController v_RoleController = new RoleController();
                RoleInfo v_RoleInfo = v_RoleController.GetRoleByName(v_Current_Portal_ID, role);

                if (v_RoleInfo != null)
                {

                    if (v_UserInfo.IsInRole(v_RoleInfo.RoleName) && mode == "remove")
                    {
                        RoleController.DeleteUserRole(v_UserInfo, v_RoleInfo, this.PortalSettings, false);
                        return Request.CreateResponse(HttpStatusCode.OK, "ok role removed");
                    }

                    if (v_UserInfo.IsInRole(v_RoleInfo.RoleName) == false && mode == "add")
                    {

                        v_RoleController.AddUserRole(v_Current_Portal_ID, userid, v_RoleInfo.RoleID, DateTime.MinValue);
                        return Request.CreateResponse(HttpStatusCode.OK, "ok role added");
                    }

                }
                else
                {

                    return Request.CreateResponse(HttpStatusCode.InternalServerError, "No such role with that RoleName");

                }

            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.InternalServerError, "No such user with that Id");
            }

            return Request.CreateResponse(HttpStatusCode.OK, "ok");

        }
开发者ID:joinsaturn,项目名称:UManage,代码行数:47,代码来源:WebApiController.cs

示例11: AddUserRole

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Adds a User to a Role
        /// </summary>
        /// <param name="user">The user to assign</param>
        /// <param name="role">The role to add</param>
        /// <param name="portalSettings">The PortalSettings of the Portal</param>
        /// <param name="status">RoleStatus</param>
        /// <param name="effectiveDate">The expiry Date of the Role membership</param>
        /// <param name="expiryDate">The expiry Date of the Role membership</param>
        /// <param name="notifyUser">A flag that indicates whether the user should be notified</param>
        /// <param name="isOwner">A flag that indicates whether this user should be one of the group owners</param>
        /// -----------------------------------------------------------------------------
        public static void AddUserRole(UserInfo user, RoleInfo role, PortalSettings portalSettings, RoleStatus status, DateTime effectiveDate, DateTime expiryDate, bool notifyUser, bool isOwner)
        {
            var roleController = new RoleController();
            var userRole = roleController.GetUserRole(portalSettings.PortalId, user.UserID, role.RoleID);
            var eventLogController = new EventLogController();

            //update assignment
            roleController.AddUserRole(portalSettings.PortalId, user.UserID, role.RoleID, status, isOwner, effectiveDate, expiryDate);

            UserController.UpdateUser(portalSettings.PortalId, user);
            if (userRole == null)
            {
                eventLogController.AddLog("Role", role.RoleName, portalSettings, user.UserID, EventLogController.EventLogType.USER_ROLE_CREATED);

                //send notification
                if (notifyUser)
                {
                    SendNotification(user, role, portalSettings, [email protected]);
                }
            }
            else
            {
                eventLogController.AddLog("Role", role.RoleName, portalSettings, user.UserID, EventLogController.EventLogType.USER_ROLE_UPDATED);
                if (notifyUser)
                {
                    roleController.GetUserRole(portalSettings.PortalId, user.UserID, role.RoleID);
                    SendNotification(user, role, portalSettings, UserRoleActions.update);
                }
            }

            //Remove the UserInfo from the Cache, as it has been modified
            DataCache.ClearUserCache(portalSettings.PortalId, user.Username);
        }
开发者ID:hungnt-me,项目名称:Dnn.Platform,代码行数:46,代码来源:RoleController.cs

示例12: cmdAdd_Click

        /// <summary>
        /// cmdAdd_Click runs when the Update Button is clicked
        /// </summary>
        /// <history>
        /// 	[cnurse]	9/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        protected void cmdAdd_Click( Object sender, EventArgs e )
        {
            try
            {
                if( Page.IsValid )
                {
                    RoleController objRoleController = new RoleController();

                    UserInfo objUser;

                    //Get the User
                    if( _userId != - 1 )
                    {
                        objUser = UserController.GetUser( PortalId, _userId, false );
                    }
                    else if( UsersControl == UsersControl.TextBox && !String.IsNullOrEmpty(txtUsers.Text) )
                    {
                        objUser = UserController.GetUserByName( PortalId, txtUsers.Text, false );
                    }
                    else if( UsersControl == UsersControl.Combo && ( cboUsers.SelectedItem != null ) )
                    {
                        objUser = UserController.GetUser( PortalId, Convert.ToInt32( cboUsers.SelectedItem.Value ), false );
                    }
                    else
                    {
                        objUser = null;
                    }

                    if( ( cboRoles.SelectedItem != null ) && ( objUser != null ) )
                    {
                        // do not modify the portal Administrator account dates
                        if( objUser.UserID == PortalSettings.AdministratorId && cboRoles.SelectedItem.Value == PortalSettings.AdministratorRoleId.ToString() )
                        {
                            txtEffectiveDate.Text = "";
                            txtExpiryDate.Text = "";
                        }

                        DateTime datEffectiveDate;
                        if( !String.IsNullOrEmpty(txtEffectiveDate.Text) )
                        {
                            datEffectiveDate = DateTime.Parse( txtEffectiveDate.Text );
                        }
                        else
                        {
                            datEffectiveDate = Null.NullDate;
                        }
                        DateTime datExpiryDate;
                        if( !String.IsNullOrEmpty(txtExpiryDate.Text) )
                        {
                            datExpiryDate = DateTime.Parse( txtExpiryDate.Text );
                        }
                        else
                        {
                            datExpiryDate = Null.NullDate;
                        }
                        EventLogController objEventLog = new EventLogController();

                        // update assignment
                        objRoleController.AddUserRole( PortalId, objUser.UserID, Convert.ToInt32( cboRoles.SelectedItem.Value ), datEffectiveDate, datExpiryDate );
                        objEventLog.AddLog( "Role", cboRoles.SelectedItem.Text, PortalSettings, _userId, EventLogController.EventLogType.USER_ROLE_CREATED );

                        // send notification
                        if( chkNotify.Checked )
                        {
                            SendNotification( objUser.UserID, Convert.ToInt32( cboRoles.SelectedItem.Value ), "add" );
                        }
                    }
                }

                BindGrid();
            }
            catch( Exception exc ) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException( this, exc );
            }
        }
开发者ID:huayang912,项目名称:cs-dotnetnuke,代码行数:83,代码来源:SecurityRoles.ascx.cs

示例13: AddUserRoles

 /// <summary>
 /// </summary>
 /// <remarks>
 /// This routine is more accurated,
 /// Prevent user assign to admin role in case user logon as LOCAL\Administrator
 /// </remarks>
 public static void AddUserRoles(int PortalID, UserInfo AuthenticationUser)
 {
     GroupController objGroupController = new GroupController();
     ArrayList colGroup = objGroupController.GetGroups();
     RoleController objRoles = new RoleController();
     GroupInfo authenticationGroup;
     try
     {
         foreach( GroupInfo tempLoopVar_authenticationGroup in colGroup )
         {
             authenticationGroup = tempLoopVar_authenticationGroup;
             if( objGroupController.IsAuthenticationMember( authenticationGroup, AuthenticationUser ) )
             {
                 objRoles.AddUserRole( PortalID, AuthenticationUser.UserID, authenticationGroup.RoleID, Null.NullDate, Null.NullDate );
             }
         }
     }
     catch( Exception exc )
     {
         Exceptions.LogException( exc );
     }
 }
开发者ID:huayang912,项目名称:cs-dotnetnuke,代码行数:28,代码来源:UserController.cs

示例14: btnSubmitAnswers_Click


//.........这里部分代码省略.........
                                   QuizId = _quizId,
                                   ReminderSent = false,
                                   UserId = UserId,
                                   UserIpAddress = Request.UserHostAddress
                               };

            //Declare placeholder for the result it
            int resultId;

            //Did they pass
            if (oResults.Percentage >= oQuizInfo.PassPercentage)
            {
                oResults.Passed = true;
                oResults.ExpirationDate = oQuizInfo.CanExpire
                                              ? DateTime.Now.AddDays(oQuizInfo.ExpireDuration)
                                              : DateTime.Now.AddYears(10);

                //Now save it
                resultId = QuizController.SaveUserQuizResults(oResults);

                var certificate = Globals.NavigateURL("QuizCert", "mid=" + ModuleId,
                                                      "quizId=" + UrlUtils.EncryptParameter(_quizId.ToString()),
                                                      "exp=" +
                                                      UrlUtils.EncryptParameter(
                                                          Server.UrlEncode(
                                                              oResults.ExpirationDate.ToShortDateString())),
                                                      "resId=" + resultId);
                var noSkinQsParams =
                    "&SkinSrc=[G]Skins%2f_default%2fNo+Skin&ContainerSrc=[G]Containers%2f_default%2fNo+Container";

                //Setup pass notification
                var notification = new StringBuilder(Localization.GetString("PassTemplate", LocalResourceFile));
                notification.Append(Localization.GetString("ReturnLinkTemplate", LocalResourceFile));
                notification.Replace("[YOURSCORE]", Math.Round(oResults.Percentage, 0).ToString());
                notification.Replace("[REQUIREDSCORE]",
                                     Math.Round(oQuizInfo.PassPercentage, 0).ToString());
                notification.Replace("[CERTLINK]", certificate);
                notification.Replace("[CERTLINKPRINT]", certificate + noSkinQsParams);
                notification.Replace("[RETURNLINK]", Globals.NavigateURL(TabId));
                lblStatus.Text = notification.ToString();

                //Add to role if needed
                if (!oQuizInfo.RoleToAdd.Equals("-1"))
                {
                    var oRoleController = new RoleController();
                    var oRoleToAdd = oRoleController.GetRoleByName(PortalId, oQuizInfo.RoleToAdd);
                    if (oRoleToAdd != null)
                    {
                        oRoleController.AddUserRole(PortalId, UserId, oRoleToAdd.RoleID,
                                                    oQuizInfo.CanExpire
                                                        ? DateTime.Now.AddDays(oQuizInfo.ExpireDuration)
                                                        : Null.NullDate);
                    }
                    else
                        Exceptions.LogException(
                            new ArgumentException("Unable to add role, unable to find " + oQuizInfo.RoleName +
                                                  " role for assignment"));
                }
            }
            else
            {
                oResults.Passed = false;
                oResults.ExpirationDate = Null.NullDate;

                //Now save it
                resultId = QuizController.SaveUserQuizResults(oResults);

                //Setup fail notification
                var takeQuizLink = Globals.NavigateURL("TakeQuiz", "mid=" + ModuleId,
                                                       "quizId=" + UrlUtils.EncryptParameter(_quizId.ToString()));
                var notification = new StringBuilder(Localization.GetString("FailTemplate", LocalResourceFile));
                notification.Append(Localization.GetString("ReturnLinkTemplate", LocalResourceFile));
                notification.Replace("[YOURSCORE]", Math.Round(oResults.Percentage, 0).ToString());
                notification.Replace("[REQUIREDSCORE]",
                                     Math.Round(oQuizInfo.PassPercentage, 0).ToString());
                notification.Replace("[TESTLINK]", takeQuizLink);
                notification.Replace("[RETURNLINK]", Globals.NavigateURL(TabId));
                lblStatus.Text = notification.ToString();

                //Setup the re-take link
                btnTakeAgain.NavigateUrl = takeQuizLink;
                btnTakeAgain.Visible = true;
            }

            //Hide the submit button
            btnSubmitAnswers.Visible = false;

            //Now, we need to save the question answers
            foreach (UserQuestionAnswerInfo oAnswer in _answers)
            {
                oAnswer.ResultId = resultId;
                QuizController.SaveUserQuestionAnswer(oAnswer);
            }

            //Now, flag for rebinding
            _questionIndex = 0;
            _finished = true;

            BindAndDisplayQuestions(_quizId);
        }
开发者ID:IowaComputerGurus,项目名称:icg.dnn.quiz,代码行数:101,代码来源:TakeQuiz.ascx.cs

示例15: CreateDNNUser

        private UserCreateStatus CreateDNNUser(MapiContact contact)
        {
            UserInfo user = new UserInfo();
            user.Email = GetUserEmailAddress(contact);
            user.Username = user.Email;
            user.FirstName = contact.NameInfo.GivenName;
            user.LastName = contact.NameInfo.Surname;
            user.DisplayName = contact.NameInfo.DisplayName;

            user.Membership.Password = UserController.GeneratePassword(12).ToString();
            user.PortalID = PortalId;
            user.IsSuperUser = false;

            UserCreateStatus createStatus = UserCreateStatus.AddUser;

            //Create the User
            createStatus = UserController.CreateUser(ref user);

            if (createStatus == UserCreateStatus.Success)
            {
                ProfileController.GetUserProfile(ref user);

                user.Profile.FirstName = contact.NameInfo.GivenName;
                user.Profile.SetProfileProperty("MiddleName", contact.NameInfo.MiddleName);
                user.Profile.LastName = contact.NameInfo.Surname;

                user.Profile.Telephone = string.IsNullOrEmpty(contact.Telephones.BusinessTelephoneNumber) ? contact.Telephones.HomeTelephoneNumber : contact.Telephones.BusinessTelephoneNumber;
                user.Profile.Cell = contact.Telephones.MobileTelephoneNumber;
                user.Profile.Website = string.IsNullOrEmpty(contact.PersonalInfo.BusinessHomePage) ? contact.PersonalInfo.Html : contact.PersonalInfo.BusinessHomePage;
                user.Profile.IM = contact.PersonalInfo.InstantMessagingAddress;

                user.Profile.Street = contact.PhysicalAddresses.HomeAddress.Street;
                user.Profile.City = contact.PhysicalAddresses.HomeAddress.City;
                user.Profile.Region = contact.PhysicalAddresses.HomeAddress.StateOrProvince;
                user.Profile.PostalCode = contact.PhysicalAddresses.HomeAddress.PostalCode;
                user.Profile.Country = contact.PhysicalAddresses.HomeAddress.Country;

                user.Profile.Street = string.IsNullOrEmpty(user.Profile.Street) ? contact.PhysicalAddresses.WorkAddress.Street : user.Profile.Street;
                user.Profile.City = string.IsNullOrEmpty(user.Profile.City) ? contact.PhysicalAddresses.WorkAddress.City : user.Profile.City;
                user.Profile.Region = string.IsNullOrEmpty(user.Profile.Region) ? contact.PhysicalAddresses.WorkAddress.StateOrProvince : user.Profile.Region;
                user.Profile.PostalCode = string.IsNullOrEmpty(user.Profile.PostalCode) ? contact.PhysicalAddresses.WorkAddress.PostalCode : user.Profile.PostalCode;
                user.Profile.Country = string.IsNullOrEmpty(user.Profile.Country) ? contact.PhysicalAddresses.WorkAddress.Country : user.Profile.Country;

                user.Profile.Street = string.IsNullOrEmpty(user.Profile.Street) ? contact.PhysicalAddresses.OtherAddress.Street : user.Profile.Street;
                user.Profile.City = string.IsNullOrEmpty(user.Profile.City) ? contact.PhysicalAddresses.OtherAddress.City : user.Profile.City;
                user.Profile.Region = string.IsNullOrEmpty(user.Profile.Region) ? contact.PhysicalAddresses.OtherAddress.StateOrProvince : user.Profile.Region;
                user.Profile.PostalCode = string.IsNullOrEmpty(user.Profile.PostalCode) ? contact.PhysicalAddresses.OtherAddress.PostalCode : user.Profile.PostalCode;
                user.Profile.Country = string.IsNullOrEmpty(user.Profile.Country) ? contact.PhysicalAddresses.OtherAddress.Country : user.Profile.Country;

                ProfileController.UpdateUserProfile(user);

                DataCache.ClearPortalCache(user.PortalID, false);

                RoleController objRoles = new RoleController();

                List<int> rolesList = new List<int>();

                foreach (int roleID in rolesList)
                {
                    objRoles.AddUserRole(user.PortalID, user.UserID, roleID, Null.NullDate, Null.NullDate);
                }
            }

            return createStatus;
        }
开发者ID:AamirWaseem,项目名称:Aspose_for_DNN,代码行数:65,代码来源:ExchangeToDnnSync.ascx.cs


注:本文中的DotNetNuke.Security.Roles.RoleController.AddUserRole方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。