Beispiel #1
0
        //*******************************************************
        //
        // The AddUser_Click server event handler is used to add
        // a new user to this security role
        //
        //*******************************************************

        private void AddUser_Click(Object sender, EventArgs e)
        {
            int userId;

            if (((LinkButton)sender).ID == "addNew")
            {
                // add new user to users table
                UsersDB users = new UsersDB();
                if ((userId = users.AddUser(windowsUserName.Text, windowsUserName.Text, "acme")) == -1)
                {
                    Message.Text = "Add New Failed!  There is already an entry for <" + "u" + ">" + windowsUserName.Text + "<" + "/u" + "> in the Users database." + "<" + "br" + ">" + "Please use Add Existing for this user.";
                }
            }
            else
            {
                //get user id from dropdownlist of existing users
                userId = Int32.Parse(allUsers.SelectedItem.Value);
            }

            if (userId != -1)
            {
                // Add a new userRole to the database
                RolesDB roles = new RolesDB();
                roles.AddUserRole(roleId, userId);
            }

            // Rebind list
            BindData();
        }
Beispiel #2
0
        //*******************************************************
        //
        // The BindData helper method is used to bind the list of
        // security roles for this portal to an asp:datalist server control
        //
        //*******************************************************

        private void BindData()
        {
            // Bind the Email and Password
            UsersDB       users = new UsersDB();
            SqlDataReader dr    = users.GetSingleUser(userName);

            // Read first row from database
            dr.Read();

            Email.Text = (String)dr["Email"];

            dr.Close();

            // add the user name to the title
            if (userName != "")
            {
                title.InnerText = "Manage User: "******"PortalSettings"];

            // Get the portal's roles from the database
            RolesDB roles = new RolesDB();

            // bind all portal roles to dropdownlist
            allRoles.DataSource = roles.GetPortalRoles(portalSettings.PortalId);
            allRoles.DataBind();
        }
Beispiel #3
0
        //*******************************************************
        //
        // The BindData helper method is used to bind the list of
        // security roles for this portal to an asp:datalist server control
        //
        //*******************************************************

        private void BindData()
        {
            // unhide the Windows Authentication UI, if application
            if (User.Identity.AuthenticationType != "Forms")
            {
                windowsUserName.Visible = true;
                addNew.Visible          = true;
            }

            // add the role name to the title
            if (roleName != "")
            {
                title.InnerText = "Role Membership: " + roleName;
            }

            // Get the portal's roles from the database
            RolesDB roles = new RolesDB();

            // bind users in role to DataList
            usersInRole.DataSource = roles.GetRoleMembers(roleId);
            usersInRole.DataBind();

            // bind all portal users to dropdownlist
            allUsers.DataSource = roles.GetUsers();
            allUsers.DataBind();
        }
Beispiel #4
0
        //*******************************************************
        //
        // The BindData helper method is used to bind the list of
        // security roles for this portal to an asp:datalist server control
        //
        //*******************************************************

        private void BindData()
        {
            // Obtain PortalSettings from Current Context
            PortalSettings portalSettings = (PortalSettings)Context.Items["PortalSettings"];

            // Get the portal's roles from the database
            RolesDB roles = new RolesDB();

            rolesList.DataSource = roles.GetPortalRoles(portalSettings.PortalId);
            rolesList.DataBind();
        }
Beispiel #5
0
        //*******************************************************
        //
        // The UserRoles_ItemCommand server event handler on this page
        // is used to handle deleting the user from roles
        // from the userRoles asp:datalist control
        //
        //*******************************************************

        private void UserRoles_ItemCommand(object sender, DataListCommandEventArgs e)
        {
            RolesDB roles  = new RolesDB();
            int     roleId = (int)userRoles.DataKeys[e.Item.ItemIndex];

            // update database
            roles.DeleteUserRole(roleId, userId);

            // Ensure that item is not editable
            userRoles.EditItemIndex = -1;

            // Repopulate list
            BindData();
        }
Beispiel #6
0
        //*******************************************************
        //
        // The BindData helper method is used to populate a asp:datalist
        // server control with the current "edit access" permissions
        // set within the portal configuration system
        //
        //*******************************************************

        private void BindData()
        {
            // Obtain PortalSettings from Current Context
            PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

            object value = GetModule();

            if (value != null)
            {
                ModuleSettings m = (ModuleSettings)value;

                // Update Textbox Settings
                moduleTitle.Text   = m.ModuleTitle;
                cacheTime.Text     = m.CacheTime.ToString();
                showMobile.Checked = m.ShowMobile;

                // Populate checkbox list with all security roles for this portal
                // and "check" the ones already configured for this module
                RolesDB       rolesObj = new RolesDB();
                SqlDataReader roles    = rolesObj.GetPortalRoles(portalSettings.PortalId);

                // Clear existing items in checkboxlist
                authEditRoles.Items.Clear();

                ListItem allItem = new ListItem();
                allItem.Text = "All Users";

                if (m.AuthorizedEditRoles.LastIndexOf("All Users") > -1)
                {
                    allItem.Selected = true;
                }

                authEditRoles.Items.Add(allItem);

                while (roles.Read())
                {
                    ListItem item = new ListItem();
                    item.Text  = (String)roles["RoleName"];
                    item.Value = roles["RoleID"].ToString();

                    if ((m.AuthorizedEditRoles.LastIndexOf(item.Text)) > -1)
                    {
                        item.Selected = true;
                    }

                    authEditRoles.Items.Add(item);
                }
            }
        }
Beispiel #7
0
        //*******************************************************
        //
        // The AddRole_Click server event handler is used to add
        // the user to this security role
        //
        //*******************************************************

        private void AddRole_Click(Object sender, EventArgs e)
        {
            int roleId;

            //get user id from dropdownlist of existing users
            roleId = Int32.Parse(allRoles.SelectedItem.Value);

            // Add a new userRole to the database
            RolesDB roles = new RolesDB();

            roles.AddUserRole(roleId, userId);

            // Rebind list
            BindData();
        }
Beispiel #8
0
        //*******************************************************
        //
        // The RolesList_ItemCommand server event handler on this page
        // is used to handle the user editing and deleting roles
        // from the RolesList asp:datalist control
        //
        //*******************************************************

        private void RolesList_ItemCommand(object sender, DataListCommandEventArgs e)
        {
            RolesDB roles  = new RolesDB();
            int     roleId = (int)rolesList.DataKeys[e.Item.ItemIndex];

            if (e.CommandName == "edit")
            {
                // Set editable list item index if "edit" button clicked next to the item
                rolesList.EditItemIndex = e.Item.ItemIndex;

                // Repopulate the datalist control
                BindData();
            }
            else if (e.CommandName == "apply")
            {
                // Apply changes
                String _roleName = ((TextBox)e.Item.FindControl("roleName")).Text;

                // update database
                roles.UpdateRole(roleId, _roleName);

                // Disable editable list item access
                rolesList.EditItemIndex = -1;

                // Repopulate the datalist control
                BindData();
            }
            else if (e.CommandName == "delete")
            {
                // update database
                roles.DeleteRole(roleId);

                // Ensure that item is not editable
                rolesList.EditItemIndex = -1;

                // Repopulate list
                BindData();
            }
            else if (e.CommandName == "members")
            {
                // Save role name changes first
                String _roleName = ((TextBox)e.Item.FindControl("roleName")).Text;
                roles.UpdateRole(roleId, _roleName);

                // redirect to edit page
                Response.Redirect("~/Admin/SecurityRoles.aspx?roleId=" + roleId + "&rolename=" + _roleName + "&tabindex=" + tabIndex + "&tabid=" + tabId);
            }
        }
Beispiel #9
0
        //*******************************************************
        //
        // The AddRole_Click server event handler is used to add
        // a new security role for this portal
        //
        //*******************************************************

        private void AddRole_Click(Object Sender, EventArgs e)
        {
            // Obtain PortalSettings from Current Context
            PortalSettings portalSettings = (PortalSettings)Context.Items["PortalSettings"];

            // Add a new role to the database
            RolesDB roles = new RolesDB();

            roles.AddRole(portalSettings.PortalId, "New Role");

            // set the edit item index to the last item
            rolesList.EditItemIndex = rolesList.Items.Count;

            // Rebind list
            BindData();
        }
Beispiel #10
0
        //*******************************************************
        //
        // The BindData helper method is used to bind the list of
        // users for this portal to an asp:DropDownList server control
        //
        //*******************************************************

        private void BindData()
        {
            // change the message between Windows and Forms authentication
            if (Context.User.Identity.AuthenticationType != "Forms")
            {
                Message.Text = "Users must be registered to view secure content.  Users may add themselves using the Register form, and Administrators may add users to specific roles using the Security Roles function above.  This section permits Administrators to manage users and their security roles directly.";
            }
            else
            {
                Message.Text = "Domain users do not need to be registered to access portal content that is available to \"All Users\".  Administrators may add domain users to specific roles using the Security Roles function above.  This section permits Administrators to manage users and their security roles directly.";
            }

            // Get the list of registered users from the database
            RolesDB roles = new RolesDB();

            // bind all portal users to dropdownlist
            allUsers.DataSource = roles.GetUsers();
            allUsers.DataBind();
        }
Beispiel #11
0
        //*******************************************************
        //
        // The BindData helper method is used to update the tab's
        // layout panes with the current configuration information
        //
        //*******************************************************

        private void BindData()
        {
            // Obtain PortalSettings from Current Context
            PortalSettings portalSettings = (PortalSettings)Context.Items["PortalSettings"];
            TabSettings    tab            = portalSettings.ActiveTab;

            // Populate Tab Names, etc.
            tabName.Text       = tab.TabName;
            mobileTabName.Text = tab.MobileTabName;
            showMobile.Checked = tab.ShowMobile;

            // Populate checkbox list with all security roles for this portal
            // and "check" the ones already configured for this tab
            RolesDB       rolesObj = new RolesDB();
            SqlDataReader roles    = rolesObj.GetPortalRoles(portalSettings.PortalId);

            // Clear existing items in checkboxlist
            authRoles.Items.Clear();

            ListItem allItem = new ListItem();

            allItem.Text = "All Users";

            if (tab.AuthorizedRoles.LastIndexOf("All Users") > -1)
            {
                allItem.Selected = true;
            }

            authRoles.Items.Add(allItem);

            while (roles.Read())
            {
                ListItem item = new ListItem();
                item.Text  = (String)roles["RoleName"];
                item.Value = roles["RoleID"].ToString();

                if ((tab.AuthorizedRoles.LastIndexOf(item.Text)) > -1)
                {
                    item.Selected = true;
                }

                authRoles.Items.Add(item);
            }

            // Populate the "Add Module" Data
            Configuration config = new Configuration();

            moduleType.DataSource = config.GetModuleDefinitions(portalSettings.PortalId);
            moduleType.DataBind();

            // Populate Right Hand Module Data
            rightList = GetModules("RightPane");
            rightPane.DataBind();

            // Populate Content Pane Module Data
            contentList = GetModules("ContentPane");
            contentPane.DataBind();

            // Populate Left Hand Pane Module Data
            leftList = GetModules("LeftPane");
            leftPane.DataBind();
        }
Beispiel #12
0
        //*******************************************************
        //
        // The ApplyChanges_Click server event handler on this page is used
        // to save the module settings into the portal configuration system
        //
        //*******************************************************

        private void ApplyChanges_Click(Object Sender, EventArgs e)
        {
            // Obtain PortalSettings from Current Context
            PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

            object value = GetModule();

            if (value != null)
            {
                ModuleSettings m = (ModuleSettings)value;

                // Construct Authorized User Roles String
                String editRoles = "";

                foreach (ListItem item in authEditRoles.Items)
                {
                    if (item.Selected == true)
                    {
                        editRoles = editRoles + item.Text + ";";
                    }
                }

                // update module
                Configuration config = new Configuration();
                config.UpdateModule(moduleId, m.ModuleOrder, m.PaneName, moduleTitle.Text, Int32.Parse(cacheTime.Text), editRoles, showMobile.Checked);

                // Update Textbox Settings
                moduleTitle.Text = m.ModuleTitle;
                cacheTime.Text   = m.CacheTime.ToString();

                // Populate checkbox list with all security roles for this portal
                // and "check" the ones already configured for this module
                RolesDB       rolesObj = new RolesDB();
                SqlDataReader roles    = rolesObj.GetPortalRoles(portalSettings.PortalId);

                // Clear existing items in checkboxlist
                authEditRoles.Items.Clear();

                ListItem allItem = new ListItem();
                allItem.Text = "All Users";

                if (m.AuthorizedEditRoles.LastIndexOf("All Users") > -1)
                {
                    allItem.Selected = true;
                }

                authEditRoles.Items.Add(allItem);

                while (roles.Read())
                {
                    ListItem item = new ListItem();
                    item.Text  = (String)roles["RoleName"];
                    item.Value = roles["RoleID"].ToString();

                    if ((m.AuthorizedEditRoles.LastIndexOf(item.Text)) > -1)
                    {
                        item.Selected = true;
                    }

                    authEditRoles.Items.Add(item);
                }
            }

            // Navigate back to admin page
            Response.Redirect("TabLayout.aspx?tabid=" + tabId);
        }