SaveAuthzRules() публичный статический Метод

public static SaveAuthzRules ( List rules ) : void
rules List
Результат void
Пример #1
0
        private void StoreSettings()
        {
            Settings.Store.LdapHost       = Regex.Split(ldapHostTextBox.Text.Trim(), @"\s+");
            Settings.Store.LdapPort       = Convert.ToInt32(ldapPortTextBox.Text.Trim());
            Settings.Store.LdapTimeout    = Convert.ToInt32(timeoutTextBox.Text.Trim());
            Settings.Store.UseSsl         = (useSslCheckBox.CheckState == CheckState.Checked);
            Settings.Store.RequireCert    = (validateServerCertCheckBox.CheckState == CheckState.Checked);
            Settings.Store.ServerCertFile = sslCertFileTextBox.Text.Trim();
            Settings.Store.SearchDN       = searchDnTextBox.Text.Trim();
            Settings.Store.SetEncryptedSetting("SearchPW", searchPassTextBox.Text);
            Settings.Store.GroupDnPattern    = this.groupDNPattern.Text.Trim();
            Settings.Store.GroupMemberAttrib = this.groupMemberAttrTB.Text.Trim();
            Settings.Store.Dereference       = this.DereferenceComboBox.SelectedIndex;

            // Authentication
            Settings.Store.AllowEmptyPasswords = this.allowEmptyPwCB.Checked;
            Settings.Store.DnPattern           = dnPatternTextBox.Text.Trim();
            Settings.Store.DoSearch            = (searchForDnCheckBox.CheckState == CheckState.Checked);
            Settings.Store.SearchFilter        = searchFilterTextBox.Text.Trim();
            Settings.Store.SearchContexts      = Regex.Split(searchContextsTextBox.Text.Trim(), @"\s*\r?\n\s*");

            // Authorization
            Settings.Store.AuthzRequireAuth  = this.authzRequireAuthCB.Checked;
            Settings.Store.AuthzAllowOnError = this.authzAllowOnErrorCB.Checked;
            List <GroupAuthzRule> lst = new List <GroupAuthzRule>();

            foreach (Object item in this.authzRulesListBox.Items)
            {
                lst.Add(item as GroupAuthzRule);
                m_logger.DebugFormat("Saving rule: {0}", item);
            }
            // Add the default as the last rule in the list
            lst.Add(new GroupAuthzRule(this.authzDefaultAllowRB.Checked));

            GroupRuleLoader.SaveAuthzRules(lst);

            // Gateway
            List <GroupGatewayRule> gwList = new List <GroupGatewayRule>();

            foreach (Object item in this.gatewayRulesListBox.Items)
            {
                gwList.Add(item as GroupGatewayRule);
                m_logger.DebugFormat("Saving rule: {0}", item);
            }
            GroupRuleLoader.SaveGatewayRules(gwList);
        }
Пример #2
0
        private void StoreSettings()
        {
            Settings.Store.LdapHost       = Regex.Split(ldapHostTextBox.Text.Trim(), @"\s+");
            Settings.Store.LdapPort       = Convert.ToInt32(ldapPortTextBox.Text.Trim());
            Settings.Store.LdapTimeout    = Convert.ToInt32(timeoutTextBox.Text.Trim());
            Settings.Store.UseSsl         = (useSslCheckBox.CheckState == CheckState.Checked);
            Settings.Store.UseTls         = (useTlsCheckBox.CheckState == CheckState.Checked);
            Settings.Store.RequireCert    = (validateServerCertCheckBox.CheckState == CheckState.Checked);
            Settings.Store.ServerCertFile = sslCertFileTextBox.Text.Trim();
            Settings.Store.UseAuthBindForAuthzAndGateway = (useAuthBindForAuthzAndGatewayCb.CheckState == CheckState.Checked);
            Settings.Store.SearchDN = searchDnTextBox.Text.Trim();
            Settings.Store.SetEncryptedSetting("SearchPW", searchPassTextBox.Text);

            // Authentication
            Settings.Store.AllowEmptyPasswords = this.allowEmptyPwCB.Checked;
            Settings.Store.DnPattern           = dnPatternTextBox.Text.Trim();
            Settings.Store.DoSearch            = (searchForDnCheckBox.CheckState == CheckState.Checked);
            Settings.Store.SearchFilter        = searchFilterTextBox.Text.Trim();
            Settings.Store.SearchContexts      = Regex.Split(searchContextsTextBox.Text.Trim(), @"\s*\r?\n\s*");
            Settings.Store.AuthzDefault        = this.authzDefaultAllowRB.Checked;

            List <string> AttribConv = new List <string>();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (row.Cells[0].Value != null && row.Cells[1].Value != null)
                {
                    AttribConv.Add(row.Cells[0].Value.ToString() + "\t" + row.Cells[1].Value.ToString().Trim());
                }
            }
            if (AttribConv.Count > 0)
            {
                Settings.Store.AttribConv = AttribConv.ToArray();
            }
            else
            {
                Settings.Store.AttribConv = new string[] { }
            };

            // Authorization
            Settings.Store.AuthzRequireAuth  = this.authzRequireAuthCB.Checked;
            Settings.Store.AuthzAllowOnError = this.authzAllowOnErrorCB.Checked;
            Settings.Store.AuthzDefault      = this.authzDefaultAllowRB.Checked;
            List <GroupAuthzRule> lst = new List <GroupAuthzRule>();

            foreach (Object item in this.authzRulesListBox.Items)
            {
                lst.Add(item as GroupAuthzRule);
                m_logger.DebugFormat("Saving rule: {0}", item);
            }
            string SaveAuthzRules_ret = GroupRuleLoader.SaveAuthzRules(lst);

            if (!string.IsNullOrEmpty(SaveAuthzRules_ret))
            {
                MessageBox.Show("There was an error in saving your authorization rules.\n" + SaveAuthzRules_ret);
            }

            // Gateway
            List <GroupGatewayRule> gwList = new List <GroupGatewayRule>();

            foreach (Object item in this.gatewayRulesListBox.Items)
            {
                gwList.Add(item as GroupGatewayRule);
                m_logger.DebugFormat("Saving rule: {0}", item);
            }
            string SaveGatewayRules_ret = GroupRuleLoader.SaveGatewayRules(gwList);

            if (!string.IsNullOrEmpty(SaveGatewayRules_ret))
            {
                MessageBox.Show("There was an error in saving your gateway rules.\n" + SaveGatewayRules_ret);
            }

            // Change Password
            List <AttributeEntry> entries = new List <AttributeEntry>();

            foreach (DataGridViewRow row in this.passwordAttributesDGV.Rows)
            {
                if (row.Cells[0].Value != null && row.Cells[1].Value != null)
                {
                    string attribName = row.Cells[0].Value.ToString();
                    if (!string.IsNullOrEmpty(attribName))
                    {
                        AttributeEntry entry = new AttributeEntry
                        {
                            Name   = attribName,
                            Method = (Methods)(row.Cells[1].Value)
                        };
                        entries.Add(entry);
                    }
                }
            }
            CPAttributeSettings.Save(entries);
        }
Пример #3
0
        private void StoreSettings()
        {
            Settings.Store.LdapHost         = Regex.Split(ldapHostTextBox.Text.Trim(), @"\s+");
            Settings.Store.LdapPort         = Convert.ToInt32(ldapPortTextBox.Text.Trim());
            Settings.Store.LdapTimeout      = Convert.ToInt32(timeoutTextBox.Text.Trim());
            Settings.Store.EncryptionMethod = (int)(GetEncryptionMethodSelection());
            Settings.Store.RequireCert      = (validateServerCertCheckBox.CheckState == CheckState.Checked);
            Settings.Store.ServerCertFile   = sslCertFileTextBox.Text.Trim();
            Settings.Store.SearchDN         = searchDnTextBox.Text.Trim();
            Settings.Store.SetEncryptedSetting("SearchPW", searchPassTextBox.Text);
            Settings.Store.GroupDnPattern                = this.groupDNPattern.Text.Trim();
            Settings.Store.GroupMemberAttrib             = this.groupMemberAttrTB.Text.Trim();
            Settings.Store.GroupGidAttrib                = this.groupGidAttr.Text.Trim();
            Settings.Store.GroupGidAttribIU              = this.groupGidAttrIU.Text.Trim();
            Settings.Store.Dereference                   = this.DereferenceComboBox.SelectedIndex;
            Settings.Store.UseAuthBindForAuthzAndGateway = this.m_useAuthBindForAuthzAndGatewayCb.Checked;

            // Authentication
            Settings.Store.AllowEmptyPasswords = this.allowEmptyPwCB.Checked;
            Settings.Store.DnPattern           = dnPatternTextBox.Text.Trim();
            Settings.Store.DoSearch            = (searchForDnCheckBox.CheckState == CheckState.Checked);
            Settings.Store.SearchFilter        = searchFilterTextBox.Text.Trim();
            Settings.Store.SearchContexts      = Regex.Split(searchContextsTextBox.Text.Trim(), @"\s*\r?\n\s*");

            // Authorization
            Settings.Store.AuthzRequireAuth     = this.authzRequireAuthCB.Checked;
            Settings.Store.AuthzAllowOnError    = this.authzAllowOnErrorCB.Checked;
            Settings.Store.AuthzApplyToAllUsers = this.authzApplyToAllUsersCB.Checked;
            List <GroupAuthzRule> lst = new List <GroupAuthzRule>();

            foreach (Object item in this.authzRulesListBox.Items)
            {
                lst.Add(item as GroupAuthzRule);
                m_logger.DebugFormat("Saving rule: {0}", item);
            }
            // Add the default as the last rule in the list
            lst.Add(new GroupAuthzRule(this.authzDefaultAllowRB.Checked));

            GroupRuleLoader.SaveAuthzRules(lst);

            // Gateway
            List <GroupGatewayRule> gwList = new List <GroupGatewayRule>();

            foreach (Object item in this.gatewayRulesListBox.Items)
            {
                gwList.Add(item as GroupGatewayRule);
                m_logger.DebugFormat("Saving rule: {0}", item);
            }
            GroupRuleLoader.SaveGatewayRules(gwList);

            // Change Password
            List <PasswordAttributeEntry> entries = new List <PasswordAttributeEntry>();

            foreach (DataGridViewRow row in this.passwordAttributesDGV.Rows)
            {
                if (row.Cells[0].Value != null && row.Cells[1].Value != null)
                {
                    string attribName = row.Cells[0].Value.ToString();
                    if (!string.IsNullOrEmpty(attribName))
                    {
                        PasswordAttributeEntry entry = new PasswordAttributeEntry
                        {
                            Name   = attribName,
                            Method = (HashMethod)(row.Cells[1].Value)
                        };
                        entries.Add(entry);
                    }
                }
            }
            CPAttributeSettings.Save(entries);

            // Login Script SFTP
            Settings.Store.SFTPServerURL     = txt_script_serverurl.Text;
            Settings.Store.SFTPUser          = txt_script_user.Text;
            Settings.Store.SFTPPassword      = txt_script_password.Text;
            Settings.Store.SFTPFingerprint   = txt_script_fingerprint.Text;
            Settings.Store.SFTPScriptPath    = txt_script_path.Text;
            Settings.Store.SFTPScriptPath2   = txt_script_path_2.Text;
            Settings.Store.SFTPGroupListPath = txt_script_group_list_path.Text;
            Settings.Store.CMDLoginScript    = txt_script_cmd_login.Text;
            Settings.Store.CMDLogoffScript   = txt_script_cmd_logoff.Text;
        }