diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs index e7102461..f4024b20 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs @@ -541,7 +541,7 @@ namespace WebsitePanel.Providers.HostedSolution var pwdLastSetDate = DateTime.FromFileTimeUtc(pwdLastSetTicks); - var expirationDate = pwdLastSetDate.AddDays(maxPasswordAgeSpan.Days); + var expirationDate = maxPasswordAgeSpan == TimeSpan.MaxValue ? DateTime.MaxValue : pwdLastSetDate.AddDays(maxPasswordAgeSpan.Days); if (expirationDate.AddDays(-daysBeforeExpiration) < DateTime.Now) { @@ -596,7 +596,15 @@ namespace WebsitePanel.Providers.HostedSolution if (sr != null && sr.Properties.Contains("maxPwdAge")) { - return TimeSpan.FromTicks((long)sr.Properties["maxPwdAge"][0]).Duration(); + try + { + return TimeSpan.FromTicks((long)sr.Properties["maxPwdAge"][0]).Duration(); + + } + catch (Exception) + { + return TimeSpan.MaxValue; + } } throw new Exception("'maxPwdAge' property not found."); @@ -1021,6 +1029,11 @@ namespace WebsitePanel.Providers.HostedSolution var pwdLastSetDate = DateTime.FromFileTimeUtc(pwdLastSetTicks); + if (maxPasswordAgeSpan == TimeSpan.MaxValue) + { + return DateTime.MaxValue; + } + return pwdLastSetDate.AddDays(maxPasswordAgeSpan.Days); } finally