Skip to content

Commit

Permalink
LDAP plugin return Message if saving auth and gateway rules fail
Browse files Browse the repository at this point in the history
- #65
  • Loading branch information
MutonUfoAI committed Jul 4, 2017
1 parent be8a74a commit 8dcf264
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
12 changes: 10 additions & 2 deletions Plugins/LdapPlugin/Ldap/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,11 @@ private void StoreSettings()
lst.Add(item as GroupAuthzRule);
m_logger.DebugFormat("Saving rule: {0}", item);
}
GroupRuleLoader.SaveAuthzRules(lst);
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>();
Expand All @@ -411,7 +415,11 @@ private void StoreSettings()
gwList.Add(item as GroupGatewayRule);
m_logger.DebugFormat("Saving rule: {0}", item);
}
GroupRuleLoader.SaveGatewayRules(gwList);
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>();
Expand Down
28 changes: 24 additions & 4 deletions Plugins/LdapPlugin/Ldap/GroupRules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,44 @@ class GroupRuleLoader
{
private static ILog m_logger = LogManager.GetLogger("LDAP GroupRuleLoader");

public static void SaveAuthzRules(List<GroupAuthzRule> rules)
public static string SaveAuthzRules(List<GroupAuthzRule> rules)
{
string ret = "";
List<string> strList = new List<string>();
foreach (GroupRule rule in rules)
{
strList.Add(rule.ToRegString());
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;
}

public static void SaveGatewayRules(List<GroupGatewayRule> rules)
public static string SaveGatewayRules(List<GroupGatewayRule> rules)
{
string ret = "";
List<string> strList = new List<string>();
foreach (GroupRule rule in rules)
{
strList.Add(rule.ToRegString());
if (GroupGatewayRule.FromRegString(rule.ToRegString()) == null)
{
ret += rule + "\n";
m_logger.ErrorFormat("Rule doesn't comply:{0}", rule);
}
else
{
strList.Add(rule.ToRegString());
}
}
Settings.Store.GroupGatewayRules = strList.ToArray();
return ret;
}

public static List<GroupAuthzRule> GetAuthzRules()
Expand Down

0 comments on commit 8dcf264

Please sign in to comment.