From 1220a131a493449a8beca2328e72985bc1d49a03 Mon Sep 17 00:00:00 2001 From: me Date: Sat, 21 Feb 2015 10:44:17 +0400 Subject: [PATCH] wsp-10318 Smart mail shows not detailed error on simple password --- .../Common/BusinessErrorCodes.cs | 1 + .../MailServers/MailServerController.cs | 11 +++++++++- .../SmarterMail10.cs | 20 ++++++++++++++----- .../WebsitePanel_SharedResources.ascx.resx | 3 +++ .../MailAccountsEditAccount.ascx.cs | 15 +++++++++++--- 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Common/BusinessErrorCodes.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Common/BusinessErrorCodes.cs index 8e8ed5ff..dc4f432d 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Common/BusinessErrorCodes.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Common/BusinessErrorCodes.cs @@ -151,6 +151,7 @@ namespace WebsitePanel.EnterpriseServer public const int ERROR_MAIL_LICENSE_USERS_QUOTA = -724; public const int ERROR_MAIL_ACCOUNT_MAX_MAILBOX_SIZE_LIMIT = -725; + public const int ERROR_MAIL_ACCOUNT_PASSWORD_NOT_COMPLEXITY = -726; #endregion #region FTP diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/MailServers/MailServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/MailServers/MailServerController.cs index 82b7e117..460b7dae 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/MailServers/MailServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/MailServers/MailServerController.cs @@ -159,7 +159,11 @@ namespace WebsitePanel.EnterpriseServer { return BusinessErrorCodes.ERROR_MAIL_LICENSE_DOMAIN_QUOTA; } - if (ex.Message != null && ex.Message.Contains("The maximum number of users for the server has been reached")) + if (ex.Message.Contains("Password doesn't meet complexity")) + { + return BusinessErrorCodes.ERROR_MAIL_ACCOUNT_PASSWORD_NOT_COMPLEXITY; + } + if (ex.Message.Contains("The maximum number of users for the server has been reached")) { return BusinessErrorCodes.ERROR_MAIL_LICENSE_USERS_QUOTA; } @@ -224,6 +228,11 @@ namespace WebsitePanel.EnterpriseServer } catch (Exception ex) { + if (ex.Message.Contains("Password doesn't meet complexity")) + { + return BusinessErrorCodes.ERROR_MAIL_ACCOUNT_PASSWORD_NOT_COMPLEXITY; + } + throw TaskManager.WriteError(ex); } finally diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail10/SmarterMail10.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail10/SmarterMail10.cs index a4b1f28f..4c4f965a 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail10/SmarterMail10.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Mail.SmarterMail10/SmarterMail10.cs @@ -1171,8 +1171,13 @@ namespace WebsitePanel.Providers.Mail mailbox.IsDomainAdmin // domain admin is false ); - if (!result.Result) - throw new Exception(result.Message); + if (!result.Result) + { + if (result.ResultCode == -21) + throw new Exception("Password doesn't meet complexity", new Exception(result.Message)); + + throw new Exception(result.Message); + } // set forwarding settings result = users.UpdateUserForwardingInfo(AdminUsername, AdminPassword, @@ -1232,10 +1237,15 @@ namespace WebsitePanel.Providers.Mail GenericResult result = users.UpdateUser( AdminUsername, AdminPassword, mailbox.Name, strPassword, mailbox.FirstName, mailbox.LastName, mailbox.IsDomainAdmin); - if (!result.Result) - throw new Exception(result.Message); + if (!result.Result) + { + if (result.ResultCode == -21) + throw new Exception("Password doesn't meet complexity", new Exception(result.Message)); + + throw new Exception(result.Message); + } - // set forwarding settings + // set forwarding settings result = users.UpdateUserForwardingInfo(AdminUsername, AdminPassword, mailbox.Name, mailbox.DeleteOnForward, (mailbox.ForwardingAddresses != null ? String.Join(", ", mailbox.ForwardingAddresses) : "")); diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx index 482edee5..4eb03c69 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_GlobalResources/WebsitePanel_SharedResources.ascx.resx @@ -402,6 +402,9 @@ Error updating mail account + + Password doesn't meet complexity. Perhaps the password length is less 5 characters. + Error updating mail domain diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/MailAccountsEditAccount.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/MailAccountsEditAccount.ascx.cs index 3418cca8..bc1bdca0 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/MailAccountsEditAccount.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/MailAccountsEditAccount.ascx.cs @@ -235,9 +235,9 @@ namespace WebsitePanel.Portal try { int result = ES.Services.MailServers.AddMailAccount(item); - if (result < 0) + if (result == BusinessErrorCodes.ERROR_MAIL_ACCOUNT_PASSWORD_NOT_COMPLEXITY) { - ShowResultMessage(result); + ShowErrorMessage("MAIL_ACCOUNT_PASSWORD_NOT_COMPLEXITY"); return; } if (result == BusinessErrorCodes.ERROR_MAIL_LICENSE_DOMAIN_QUOTA) @@ -250,7 +250,11 @@ namespace WebsitePanel.Portal ShowResultMessage(result); return; } - + if (result < 0) + { + ShowResultMessage(result); + return; + } } catch (Exception ex) { @@ -264,6 +268,11 @@ namespace WebsitePanel.Portal try { int result = ES.Services.MailServers.UpdateMailAccount(item); + if (result == BusinessErrorCodes.ERROR_MAIL_ACCOUNT_PASSWORD_NOT_COMPLEXITY) + { + ShowErrorMessage("MAIL_ACCOUNT_PASSWORD_NOT_COMPLEXITY"); + return; + } if (result < 0) { ShowResultMessage(result);