password reset fixes

This commit is contained in:
vfedosevich 2015-04-20 03:01:21 -07:00
parent 69b1bc2f16
commit 087697ba7f
18 changed files with 133 additions and 46 deletions

View file

@ -9850,7 +9850,7 @@ Hello #user.FirstName#,
Your password expiration date is #user.PasswordExpirationDateTime#. You can reset your own password by visiting the following page:
</p>
<a href="#passwordResetLink#">#passwordResetLink#</a>
<a href="#passwordResetLink#" target="_blank">#passwordResetLink#</a>
<p>
@ -9963,7 +9963,7 @@ Hello #user.FirstName#,
We received a request to reset the password for your account. If you made this request, click the link below. If you did not make this request, you can ignore this email.
</p>
<a href="#passwordResetLink#">#passwordResetLink#</a>
<a href="#passwordResetLink#" target="_blank">#passwordResetLink#</a>
<p>
@ -10139,10 +10139,12 @@ Set @ExchangeMailboxSetupLetterHtmlBody = N'<html xmlns="http://www.w3.org/1999/
<td class="Label">E-mail:</td>
<td>#Account.PrimaryEmailAddress#</td>
</tr>
<ad:if test="#PswResetUrl#">
<tr>
<td class="Label">Password Reset Url:</td>
<td><a href="#PswResetUrl#">Click here</a></td>
<td><a href="#PswResetUrl#" target="_blank">Click here</a></td>
</tr>
</ad:if>
</table>
</ad:if>
<h1>DNS</h1>
@ -10308,8 +10310,10 @@ The following user accounts have been created for you.
Username: #Account.UserPrincipalName#
E-mail: #Account.PrimaryEmailAddress#
<ad:if test="#PswResetUrl#">
Password Reset Url: #PswResetUrl#
</ad:if>
</ad:if>
=================================
DNS

View file

@ -27,6 +27,7 @@
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Linq;
using System.Xml;
using System.Collections.Generic;
using System.Text;
@ -46,6 +47,7 @@ namespace WebsitePanel.EnterpriseServer
public const string PACKAGE_DISPLAY_SETTINGS = "PackageDisplaySettings";
public const string RDS_SETTINGS = "RdsSettings";
public const string WEBDAV_PORTAL_SETTINGS = "WebdavPortalSettings";
public const string WEBDAV_PASSWORD_RESET_ENABLED_KEY = "WebdavPasswordResetEnabled";
// key to access to wpi main & custom feed in wpi settings
public const string WPI_MAIN_FEED_KEY = "WpiMainFeedUrl";
@ -98,6 +100,24 @@ namespace WebsitePanel.EnterpriseServer
}
}
public bool Contains(string settingName)
{
return Settings.AllKeys.Any(x => x.ToLowerInvariant() == (settingName ?? string.Empty).ToLowerInvariant());
}
public T GetValueOrDefault<T>(string settingName, T defaultValue)
{
try
{
return (T)Convert.ChangeType(Settings[settingName], typeof(T));
}
catch
{
}
return defaultValue;
}
public int GetInt(string settingName)
{
return Int32.Parse(Settings[settingName]);

View file

@ -2613,10 +2613,16 @@ namespace WebsitePanel.EnterpriseServer
// add account
items["Account"] = account;
items["PswResetUrl"] = OrganizationController.GenerateUserPasswordResetLink(account.ItemId, account.AccountId);
items["AccountDomain"] = account.PrimaryEmailAddress.Substring(account.PrimaryEmailAddress.IndexOf("@") + 1);
items["DefaultDomain"] = org.DefaultDomain;
var passwordResetUrl = OrganizationController.GenerateUserPasswordResetLink(account.ItemId, account.AccountId);
if (!string.IsNullOrEmpty(passwordResetUrl))
{
items["PswResetUrl"] = passwordResetUrl;
}
if (!String.IsNullOrEmpty(account.SamAccountName))
{
int idx = account.SamAccountName.IndexOf("\\");

View file

@ -1684,6 +1684,11 @@ namespace WebsitePanel.EnterpriseServer
throw new Exception("Webdav portal system settings are not set");
}
if (!settings.GetValueOrDefault(SystemSettings.WEBDAV_PASSWORD_RESET_ENABLED_KEY, false) ||!settings.Contains("WebdavPortalUrl"))
{
return string.Empty;
}
var webdavPortalUrl = new Uri(settings["WebdavPortalUrl"]);
var token = CreateAccessToken(itemId, accountId, AccessTokenTypes.PasswrodReset);
@ -1794,11 +1799,12 @@ namespace WebsitePanel.EnterpriseServer
NumbersCount = Utils.ParseInt(parts[4], 0),
SymbolsCount = Utils.ParseInt(parts[5], 0),
AccountLockoutThreshold = Utils.ParseInt(parts[7], 0),
EnforcePasswordHistory = Utils.ParseInt(parts[8], 0),
AccountLockoutDuration = Utils.ParseInt(parts[9], 0),
ResetAccountLockoutCounterAfter = Utils.ParseInt(parts[10], 0),
LockoutSettingsEnabled = Utils.ParseBool(parts[11], false),
PasswordComplexityEnabled = Utils.ParseBool(parts[12], true),
EnforcePasswordHistory = GetValueSafe(parts, 8, 0),
AccountLockoutDuration = GetValueSafe(parts, 9, 0),
ResetAccountLockoutCounterAfter = GetValueSafe(parts, 10, 0),
LockoutSettingsEnabled = GetValueSafe(parts, 11, false),
PasswordComplexityEnabled = GetValueSafe(parts, 11, true),
};
@ -1821,6 +1827,21 @@ namespace WebsitePanel.EnterpriseServer
return passwordSettings;
}
public static T GetValueSafe<T>(string[] array, int index, T defaultValue)
{
if (array.Length > index)
{
if (string.IsNullOrEmpty(array[index]))
{
return defaultValue;
}
return (T)Convert.ChangeType(array[index], typeof(T));
}
return defaultValue;
}
public static void UpdateOrganizationGeneralSettings(int itemId, OrganizationGeneralSettings settings)
{
TaskManager.StartTask("ORGANIZATION", "UPDATE_GENERAL_SETTINGS");

View file

@ -44,7 +44,17 @@ namespace WebsitePanel.WebDavPortal.Controllers
return RedirectToRoute(FileSystemRouteNames.ShowContentPath, new { org = WspContext.User.OrganizationId });
}
return View();
var model = new AccountModel();
var settings = WspContext.Services.System.GetSystemSettings(EnterpriseServer.SystemSettings.WEBDAV_PORTAL_SETTINGS);
if (settings != null)
{
model.PasswordResetEnabled = settings.GetValueOrDefault(EnterpriseServer.SystemSettings.WEBDAV_PASSWORD_RESET_ENABLED_KEY, false);
}
return View(model);
}
[HttpPost]

View file

@ -17,5 +17,7 @@ namespace WebsitePanel.WebDavPortal.Models
public string Password { get; set; }
public string LdapError { get; set; }
public bool PasswordResetEnabled { get; set; }
}
}

View file

@ -9,6 +9,7 @@
<br/>
<div class="container row">
<form class="form-horizontal" method="POST" role="form">
@Html.HiddenFor(x=>x.PasswordResetEnabled)
<div class="form-group">
<h3 class="col-sm-offset-1">Sign In</h3>
</div>
@ -33,7 +34,10 @@
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Sign in</button>
@if (Model.PasswordResetEnabled)
{
<a href="@Url.RouteUrl(AccountRouteNames.PasswordResetEmail)" class="forgot-your-password-link">@UI.ForgotYourPassword</a>
}
</div>
</div>
</form>

View file

@ -28,11 +28,14 @@
<div class="navbar navbar-inverse navbar-fixed-top prevent-deselect">
<div class="container top-container">
<div class="navbar-header">
@if (WspContext.User != null)
{
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
}
<a href="/">
<img class="header-logo processing-dialog" src="@Url.Content("~/Content/Images/logo.png")" />
</a>

View file

@ -174,4 +174,10 @@
<data name="WebdavPortalSettings.Text" xml:space="preserve">
<value>Webdav Portal</value>
</data>
<data name="chkEnablePasswordReset.Text" xml:space="preserve">
<value>Yes</value>
</data>
<data name="locEnablePasswordReset.Text" xml:space="preserve">
<value>Enable password reset:</value>
</data>
</root>

View file

@ -267,4 +267,7 @@
<data name="Text.DeletedUsers" xml:space="preserve">
<value>Deleted Users</value>
</data>
<data name="Text.PasswordPolicy" xml:space="preserve">
<value>Password Policy</value>
</data>
</root>

View file

@ -37,14 +37,6 @@
<asp:Label runat="server" ID="lblCreatedValue" />
</td>
</tr>
<tr>
<td class="OrgStatsRow">
<asp:Label runat="server" meta:resourcekey="OrganizationSettings" ID="Label1" />
</td>
<td>
<asp:HyperLink ID="lnkEditOrganizationSettings" runat="server" meta:resourcekey="lnkEditOrganizationSettings"></asp:HyperLink>
</td>
</tr>
</table>
<br />
<table width="100%">

View file

@ -175,9 +175,6 @@ namespace WebsitePanel.Portal.ExchangeServer
lblOrganizationNameValue.Text = org.Name;
lblOrganizationIDValue.Text = org.OrganizationId;
lblCreatedValue.Text = org.CreatedDate.Date.ToShortDateString();
lnkEditOrganizationSettings.NavigateUrl = EditUrl("ItemID", PanelRequest.ItemID.ToString(), "organization_settings_password_settings",
"SpaceID=" + PanelSecurity.PackageId);
OrganizationStatistics orgStats = ES.Services.Organizations.GetOrganizationStatisticsByOrganization(PanelRequest.ItemID);
OrganizationStatistics tenantStats = ES.Services.Organizations.GetOrganizationStatistics(PanelRequest.ItemID);

View file

@ -84,24 +84,6 @@ namespace WebsitePanel.Portal.ExchangeServer {
/// </remarks>
protected global::System.Web.UI.WebControls.Label lblCreatedValue;
/// <summary>
/// Label1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label Label1;
/// <summary>
/// lnkEditOrganizationSettings control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.HyperLink lnkEditOrganizationSettings;
/// <summary>
/// organizationStatsPanel control.
/// </summary>

View file

@ -221,6 +221,14 @@ namespace WebsitePanel.Portal.HostedSolution
password.ValidationEnabled = true;
password.Password = string.Empty;
var settings = ES.Services.System.GetSystemSettings(EnterpriseServer.SystemSettings.WEBDAV_PORTAL_SETTINGS);
if (settings != null)
{
btnResetUserPassword.Visible = Utils.ParseBool(settings[EnterpriseServer.SystemSettings.WEBDAV_PASSWORD_RESET_ENABLED_KEY], false);
}
chkUserMustChangePassword.Checked = user.UserMustChangePassword;
}
catch (Exception ex)

View file

@ -86,6 +86,12 @@
<wsp:CollapsiblePanel ID="WebdavPortalSettings" runat="server" TargetControlID="PanelWebdavPortalSettings" meta:resourcekey="WebdavPortalSettings" Text="Webdav Portal" />
<asp:Panel ID="PanelWebdavPortalSettings" runat="server" Height="0" style="overflow:hidden;">
<table>
<tr>
<td class="SubHead"><asp:Localize ID="locEnablePasswordReset" runat="server" meta:resourcekey="locEnablePasswordReset" /></td>
<td class="Normal">
<asp:CheckBox ID="chkEnablePasswordReset" runat="server" Text="Yes" meta:resourcekey="chkEnablePasswordReset" />
</td>
</tr>
<tr>
<td class="SubHead" style="width:200px;"><asp:Localize ID="lblWebdavPortalUrl" runat="server" meta:resourcekey="lblWebdavPortalUrl" />
<td><asp:TextBox runat="server" ID="txtWebdavPortalUrl" Width="450px" /></td>

View file

@ -53,6 +53,7 @@ namespace WebsitePanel.Portal
public const string FILE_MANAGER_EDITABLE_EXTENSIONS = "EditableExtensions";
public const string RDS_MAIN_CONTROLLER = "RdsMainController";
public const string WEBDAV_PORTAL_URL = "WebdavPortalUrl";
public const string WEBDAV_PASSWORD_RESET_ENABLED = "WebdavPasswordResetEnabled";
/*
public const string FEED_ENABLE_MICROSOFT = "FeedEnableMicrosoft";
@ -163,6 +164,7 @@ namespace WebsitePanel.Portal
if (settings != null)
{
chkEnablePasswordReset.Checked = Utils.ParseBool(settings[WEBDAV_PASSWORD_RESET_ENABLED], false);
txtWebdavPortalUrl.Text = settings[WEBDAV_PORTAL_URL];
}
}
@ -248,6 +250,7 @@ namespace WebsitePanel.Portal
settings = new WSP.SystemSettings();
settings[WEBDAV_PORTAL_URL] = txtWebdavPortalUrl.Text;
settings[WEBDAV_PASSWORD_RESET_ENABLED] = chkEnablePasswordReset.Checked.ToString();
result = ES.Services.System.SetSystemSettings(WSP.SystemSettings.WEBDAV_PORTAL_SETTINGS, settings);
if (result < 0)

View file

@ -246,6 +246,24 @@ namespace WebsitePanel.Portal {
/// </remarks>
protected global::System.Web.UI.WebControls.Panel PanelWebdavPortalSettings;
/// <summary>
/// locEnablePasswordReset control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Localize locEnablePasswordReset;
/// <summary>
/// chkEnablePasswordReset control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.CheckBox chkEnablePasswordReset;
/// <summary>
/// lblWebdavPortalUrl control.
/// </summary>

View file

@ -181,6 +181,8 @@ namespace WebsitePanel.Portal.UserControls
if (Utils.CheckQouta(Quotas.ORGANIZATION_SECURITYGROUPS, Cntx))
items.Add(CreateMenuItem("SecurityGroups", "secur_groups", @"Icons/group_48.png"));
items.Add(CreateMenuItem("PasswordPolicy", "organization_settings_password_settings", @"Icons/user_48.png"));
}
private void PrepareExchangeMenuRoot(MenuItemCollection items)