Exemplo n.º 1
0
        /// <summary>
        /// The BindData helper method is used to bind the list of
        /// security roles for this portal to an asp:datalist server control
        /// </summary>
        private void BindData()
        {
            // Bind the Email and Password
            UsersDB users = new UsersDB();

            Guid currentUserID = this.userID;// PortalSettings.CurrentUser.Identity.ProviderUserKey;
            // bind users in role to DataList
            IList<AppleseedRole> roles = new List<AppleseedRole>();
            try {
                roles = users.GetRolesByUser(currentUserID, this.PortalSettings.PortalAlias);
            } catch (Exception exc) {
                ErrorHandler.Publish(LogLevel.Error, exc);
            }
            userRoles.DataKeyField = "Id";
            userRoles.DataSource = roles;
            userRoles.DataBind();

            // bind all portal roles to dropdownlist
            IList<AppleseedRole> allRolesList = users.GetPortalRoles(this.PortalSettings.PortalAlias);

            // remove "All Users", "Authenticated Users" and "Unauthenticated Users" pseudo-roles
            AppleseedRole pseudoRole = new AppleseedRole(AppleseedRoleProvider.AllUsersGuid, AppleseedRoleProvider.AllUsersRoleName);

            if (allRolesList.Contains(pseudoRole))
            {
                allRolesList.Remove(pseudoRole);
            }
            pseudoRole = new AppleseedRole(AppleseedRoleProvider.AuthenticatedUsersGuid, AppleseedRoleProvider.AuthenticatedUsersRoleName);
            if (allRolesList.Contains(pseudoRole))
            {
                allRolesList.Remove(pseudoRole);
            }
            pseudoRole = new AppleseedRole(AppleseedRoleProvider.UnauthenticatedUsersGuid, AppleseedRoleProvider.UnauthenticatedUsersRoleName);
            if (allRolesList.Contains(pseudoRole))
            {
                allRolesList.Remove(pseudoRole);
            }

            allRoles.DataSource = allRolesList;
            allRoles.DataBind();
        }