private void authzRuleAddButton_Click(object sender, EventArgs e) { string path = this.authzRulePathTB.Text.Trim(); if (string.IsNullOrEmpty(path)) { MessageBox.Show("Please enter a DN"); return; } int idx = this.authzRuleMemberComboBox.SelectedIndex; GroupRule.Condition c; if (idx == 0) { c = GroupRule.Condition.MEMBER_OF; } else if (idx == 1) { c = GroupRule.Condition.NOT_MEMBER_OF; } else { throw new Exception("Unrecognized option in authzRuleAddButton_Click"); } idx = this.authzRuleActionComboBox.SelectedIndex; bool allow; if (idx == 0) { allow = true; // allow } else if (idx == 1) { allow = false; // deny } else { throw new Exception("Unrecognized action option in authzRuleAddButton_Click"); } string filter = this.authzRuleFilter.Text.Trim(); if (string.IsNullOrEmpty(path)) { MessageBox.Show("Please enter a search filter"); return; } SearchScope search = (SearchScope)this.authzRuleScope.SelectedIndex; GroupAuthzRule rule = new GroupAuthzRule(path, c, allow, filter, search); this.authzRulesListBox.Items.Add(rule); }
private void authzRuleAddButton_Click(object sender, EventArgs e) { string grp = this.authzRuleGroupTB.Text.Trim(); if (string.IsNullOrEmpty(grp)) { MessageBox.Show("Please enter a group name."); return; } int idx = this.authzRuleMemberComboBox.SelectedIndex; GroupRule.Condition c; if (idx == 0) { c = GroupRule.Condition.MEMBER_OF; } else if (idx == 1) { c = GroupRule.Condition.NOT_MEMBER_OF; } else { throw new Exception("Unrecognized option in authzRuleAddButton_Click"); } idx = this.authzRuleActionComboBox.SelectedIndex; bool allow; if (idx == 0) { allow = true; // allow } else if (idx == 1) { allow = false; // deny } else { throw new Exception("Unrecognized action option in authzRuleAddButton_Click"); } GroupAuthzRule rule = new GroupAuthzRule(grp, c, allow); this.authzRulesListBox.Items.Add(rule); }
public static List <GroupAuthzRule> GetAuthzRules() { List <GroupAuthzRule> rules = new List <GroupAuthzRule>(); string[] strRules = Settings.Store.GroupAuthzRules; foreach (string str in strRules) { GroupAuthzRule rule = GroupAuthzRule.FromRegString(str); if (rule != null) { rules.Add(rule); } // else // Log error //m_logger.ErrorFormat("Unrecognized registry entry when loading authorization rule, ignoring: {0}", str); } return(rules); }
public static string SaveAuthzRules(List <GroupAuthzRule> rules) { string ret = ""; List <string> strList = new List <string>(); foreach (GroupRule rule in rules) { if (GroupAuthzRule.FromRegString(rule.ToRegString()) == null) { ret += rule + "\n"; m_logger.ErrorFormat("Rule doesn't comply:{0}", rule); } else { strList.Add(rule.ToRegString()); } } Settings.Store.GroupAuthzRules = strList.ToArray(); return(ret); }
private void authzRuleAddButton_Click(object sender, EventArgs e) { string path = this.authzRulePathTB.Text.Trim(); if (string.IsNullOrEmpty(path)) { MessageBox.Show("Please enter a DN"); return; } int idx = this.authzRuleMemberComboBox.SelectedIndex; GroupRule.Condition c; if (idx == 0) c = GroupRule.Condition.MEMBER_OF; else if (idx == 1) c = GroupRule.Condition.NOT_MEMBER_OF; else throw new Exception("Unrecognized option in authzRuleAddButton_Click"); idx = this.authzRuleActionComboBox.SelectedIndex; bool allow; if (idx == 0) allow = true; // allow else if (idx == 1) allow = false; // deny else throw new Exception("Unrecognized action option in authzRuleAddButton_Click"); string filter = this.authzRuleFilter.Text.Trim(); if (string.IsNullOrEmpty(path)) { MessageBox.Show("Please enter a search filter"); return; } SearchScope search = (SearchScope)this.authzRuleScope.SelectedIndex; GroupAuthzRule rule = new GroupAuthzRule(path, c, allow, filter, search); this.authzRulesListBox.Items.Add(rule); }
private void authzRuleAddButton_Click(object sender, EventArgs e) { string grp = this.authzRuleGroupTB.Text.Trim(); if (string.IsNullOrEmpty(grp)) { MessageBox.Show("Please enter a group name."); return; } int idx = this.authzRuleMemberComboBox.SelectedIndex; GroupRule.Condition c; if (idx == 0) c = GroupRule.Condition.MEMBER_OF; else if (idx == 1) c = GroupRule.Condition.NOT_MEMBER_OF; else throw new Exception("Unrecognized option in authzRuleAddButton_Click"); idx = this.authzRuleActionComboBox.SelectedIndex; bool allow; if (idx == 0) allow = true; // allow else if (idx == 1) allow = false; // deny else throw new Exception("Unrecognized action option in authzRuleAddButton_Click"); GroupAuthzRule rule = new GroupAuthzRule(grp, c, allow); this.authzRulesListBox.Items.Add(rule); }
private void LoadSettings() { string[] ldapHosts = Settings.Store.LdapHost; string hosts = ""; for (int i = 0; i < ldapHosts.Count(); i++) { string host = ldapHosts[i]; if (i < ldapHosts.Count() - 1) { hosts += host + " "; } else { hosts += host; } } ldapHostTextBox.Text = hosts; int port = Settings.Store.LdapPort; ldapPortTextBox.Text = Convert.ToString(port); int timeout = Settings.Store.LdapTimeout; timeoutTextBox.Text = Convert.ToString(timeout); int encryptionMethod = Settings.Store.EncryptionMethod; m_encryptionMethodCb.SelectedIndex = encryptionMethod; bool reqCert = Settings.Store.RequireCert; validateServerCertCheckBox.CheckState = reqCert ? CheckState.Checked : CheckState.Unchecked; string serverCertFile = Settings.Store.ServerCertFile; sslCertFileTextBox.Text = serverCertFile; string searchDn = Settings.Store.SearchDN; searchDnTextBox.Text = searchDn; string searchPw = Settings.Store.GetEncryptedSetting("SearchPW"); searchPassTextBox.Text = searchPw; string grpDnPattern = Settings.Store.GroupDnPattern; this.groupDNPattern.Text = grpDnPattern; string grpMemberAttrib = Settings.Store.GroupMemberAttrib; this.groupMemberAttrTB.Text = grpMemberAttrib; string GroupGidAttrib = Settings.Store.GroupGidAttrib; this.groupGidAttr.Text = GroupGidAttrib; string GroupGidAttribIU = Settings.Store.GroupGidAttribIU; this.groupGidAttrIU.Text = GroupGidAttribIU; int derefValue = Settings.Store.Dereference; this.DereferenceComboBox.SelectedIndex = derefValue; // Authentication tab bool allowEmpty = Settings.Store.AllowEmptyPasswords; this.allowEmptyPwCB.Checked = allowEmpty; string dnPattern = Settings.Store.DnPattern; dnPatternTextBox.Text = dnPattern; bool doSearch = Settings.Store.DoSearch; searchForDnCheckBox.CheckState = doSearch ? CheckState.Checked : CheckState.Unchecked; string filter = Settings.Store.SearchFilter; searchFilterTextBox.Text = filter; bool useAuth = Settings.Store.UseAuthBindForAuthzAndGateway; m_useAuthBindForAuthzAndGatewayCb.Checked = useAuth; string[] searchContexts = Settings.Store.SearchContexts; string ctxs = ""; for (int i = 0; i < searchContexts.Count(); i++) { string ctx = searchContexts[i]; if (i < searchContexts.Count() - 1) { ctxs += ctx + "\r\n"; } else { ctxs += ctx; } } searchContextsTextBox.Text = ctxs; /////////////// Authorization tab ///////////////// this.authzRuleMemberComboBox.SelectedIndex = 0; this.authzRuleActionComboBox.SelectedIndex = 0; this.authzRequireAuthCB.Checked = Settings.Store.AuthzRequireAuth; this.authzAllowOnErrorCB.Checked = Settings.Store.AuthzAllowOnError; this.authzApplyToAllUsersCB.Checked = Settings.Store.AuthzApplyToAllUsers; List <GroupAuthzRule> lst = GroupRuleLoader.GetAuthzRules(); // The last one should be the default rule if (lst.Count > 0 && lst[lst.Count - 1].RuleCondition == GroupRule.Condition.ALWAYS) { GroupAuthzRule rule = lst[lst.Count - 1]; if (rule.AllowOnMatch) { this.authzDefaultAllowRB.Checked = true; } else { this.authzDefaultDenyRB.Checked = true; } lst.RemoveAt(lst.Count - 1); } else { // The list is empty or the last rule is not a default rule. throw new Exception("Default rule not found in rule list."); } // The rest of the rules foreach (GroupAuthzRule rule in lst) { this.authzRulesListBox.Items.Add(rule); } ///////////////// Gateway tab ///////////////// List <GroupGatewayRule> gwLst = GroupRuleLoader.GetGatewayRules(); foreach (GroupGatewayRule rule in gwLst) { this.gatewayRulesListBox.Items.Add(rule); } ////////////// Change Password tab /////////////// List <PasswordAttributeEntry> attribs = CPAttributeSettings.Load(); foreach (PasswordAttributeEntry entry in attribs) { this.passwordAttributesDGV.Rows.Add(entry.Name, entry.Method); } ///////////// Login Script //////////////// txt_script_serverurl.Text = Settings.Store.SFTPServerURL; txt_script_user.Text = Settings.Store.SFTPUser; txt_script_password.Text = Settings.Store.SFTPPassword; txt_script_fingerprint.Text = Settings.Store.SFTPFingerprint; txt_script_path.Text = Settings.Store.SFTPScriptPath; txt_script_path_2.Text = Settings.Store.SFTPScriptPath2; txt_script_group_list_path.Text = Settings.Store.SFTPGroupListPath; txt_script_cmd_login.Text = Settings.Store.CMDLoginScript; txt_script_cmd_logoff.Text = Settings.Store.CMDLogoffScript; }
private void LoadSettings() { string[] ldapHosts = Settings.Store.LdapHost; string hosts = ""; for (int i = 0; i < ldapHosts.Count(); i++) { string host = ldapHosts[i]; if (i < ldapHosts.Count() - 1) { hosts += host + " "; } else { hosts += host; } } ldapHostTextBox.Text = hosts; int port = Settings.Store.LdapPort; ldapPortTextBox.Text = Convert.ToString(port); int timeout = Settings.Store.LdapTimeout; timeoutTextBox.Text = Convert.ToString(timeout); bool useSsl = Settings.Store.UseSsl; useSslCheckBox.CheckState = useSsl ? CheckState.Checked : CheckState.Unchecked; bool reqCert = Settings.Store.RequireCert; validateServerCertCheckBox.CheckState = reqCert ? CheckState.Checked : CheckState.Unchecked; string serverCertFile = Settings.Store.ServerCertFile; sslCertFileTextBox.Text = serverCertFile; string searchDn = Settings.Store.SearchDN; searchDnTextBox.Text = searchDn; string searchPw = Settings.Store.GetEncryptedSetting("SearchPW"); searchPassTextBox.Text = searchPw; string grpDnPattern = Settings.Store.GroupDnPattern; this.groupDNPattern.Text = grpDnPattern; string grpMemberAttrib = Settings.Store.GroupMemberAttrib; this.groupMemberAttrTB.Text = grpMemberAttrib; int derefValue = Settings.Store.Dereference; this.DereferenceComboBox.SelectedIndex = derefValue; // Authentication tab bool allowEmpty = Settings.Store.AllowEmptyPasswords; this.allowEmptyPwCB.Checked = allowEmpty; string dnPattern = Settings.Store.DnPattern; dnPatternTextBox.Text = dnPattern; bool doSearch = Settings.Store.DoSearch; searchForDnCheckBox.CheckState = doSearch ? CheckState.Checked : CheckState.Unchecked; string filter = Settings.Store.SearchFilter; searchFilterTextBox.Text = filter; string[] searchContexts = Settings.Store.SearchContexts; string ctxs = ""; for (int i = 0; i < searchContexts.Count(); i++) { string ctx = searchContexts[i]; if (i < searchContexts.Count() - 1) { ctxs += ctx + "\r\n"; } else { ctxs += ctx; } } searchContextsTextBox.Text = ctxs; /////////////// Authorization tab ///////////////// this.authzRuleMemberComboBox.SelectedIndex = 0; this.authzRuleActionComboBox.SelectedIndex = 0; this.authzRequireAuthCB.Checked = Settings.Store.AuthzRequireAuth; this.authzAllowOnErrorCB.Checked = Settings.Store.AuthzAllowOnError; List <GroupAuthzRule> lst = GroupRuleLoader.GetAuthzRules(); // The last one should be the default rule if (lst.Count > 0 && lst[lst.Count - 1].RuleCondition == GroupRule.Condition.ALWAYS) { GroupAuthzRule rule = lst[lst.Count - 1]; if (rule.AllowOnMatch) { this.authzDefaultAllowRB.Checked = true; } else { this.authzDefaultDenyRB.Checked = true; } lst.RemoveAt(lst.Count - 1); } else { // The list is empty or the last rule is not a default rule. throw new Exception("Default rule not found in rule list."); } // The rest of the rules foreach (GroupAuthzRule rule in lst) { this.authzRulesListBox.Items.Add(rule); } ///////////////// Gateway tab ///////////////// List <GroupGatewayRule> gwLst = GroupRuleLoader.GetGatewayRules(); foreach (GroupGatewayRule rule in gwLst) { this.gatewayRulesListBox.Items.Add(rule); } }