Added change user principalName

Added button to change user password
Changes EmailAddresses, user principal name disabled
This commit is contained in:
robvde 2012-11-24 11:39:42 +04:00
parent 8a4159a0ff
commit 4c75df5a73
21 changed files with 850 additions and 153 deletions

View file

@ -239,4 +239,13 @@
<data name="lblUserPrincipalName" xml:space="preserve">
<value>Login Name:</value>
</data>
<data name="btnSetUserPassword.Text" xml:space="preserve">
<value>Set Password</value>
</data>
<data name="btnSetUserPrincipalName.Text" xml:space="preserve">
<value>Set Login Name</value>
</data>
<data name="chkInherit.Text" xml:space="preserve">
<value>Set login name for services</value>
</data>
</root>

View file

@ -73,7 +73,7 @@
<asp:CheckBox ID="chkSelectAll" runat="server" onclick="javascript:SelectAllCheckboxes(this);" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" Enabled='<%# !(bool)Eval("IsPrimary") %>' />
<asp:CheckBox ID="chkSelect" runat="server" Enabled='<%# !((bool)Eval("IsPrimary") | (bool)Eval("IsUserPrincipalName"))%>' />
</ItemTemplate>
<ItemStyle Width="10px" />
</asp:TemplateField>
@ -87,7 +87,7 @@
<ItemTemplate>
<div style="text-align:center">
&nbsp;
<asp:Image ID="Image1" runat="server" SkinID="Checkbox16" Visible='<%# Eval("IsPrimary") %>' />
<asp:Image ID="Image1" runat="server" SkinID="Checkbox16" Visible='<%# (bool)Eval("IsPrimary")%>' />
</div>
</ItemTemplate>
</asp:TemplateField>

View file

@ -182,14 +182,5 @@ namespace WebsitePanel.Portal.ExchangeServer {
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.CheckBox chkPmmAllowed;
/// <summary>
/// FormComments 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 FormComments;
}
}

View file

@ -4,7 +4,7 @@
<%@ Register Src="../UserControls/SimpleMessageBox.ascx" TagName="SimpleMessageBox" TagPrefix="wsp" %>
<%@ Register Src="../UserControls/PasswordControl.ascx" TagName="PasswordControl" TagPrefix="wsp" %>
<%@ Register TagPrefix="wsp" TagName="CollapsiblePanel" Src="../UserControls/CollapsiblePanel.ascx" %>
<%@ Register Src="../UserControls/CollapsiblePanel.ascx" TagName="CollapsiblePanel" TagPrefix="wsp" %>
<%@ Register Src="../UserControls/EnableAsyncTasksSupport.ascx" TagName="EnableAsyncTasksSupport" TagPrefix="wsp" %>
<%@ Register Src="UserControls/Menu.ascx" TagName="Menu" TagPrefix="wsp" %>
<%@ Register Src="UserControls/Breadcrumb.ascx" TagName="Breadcrumb" TagPrefix="wsp" %>
@ -47,7 +47,15 @@
<td>
<asp:Label runat="server" ID="lblUserPrincipalName" />
<wsp:EmailAddress id="upn" runat="server" ValidationGroup="CreateMailbox"></wsp:EmailAddress>
<asp:DropDownList ID="ddlEmailAddresses" runat="server" CssClass="NormalTextBox"></asp:DropDownList>
</td>
<td>
<asp:Button id="btnSetUserPrincipalName" runat="server" Text="Set Login" CssClass="Button1"
meta:resourcekey="btnSetUserPrincipalName" OnClick="btnSetUserPrincipalName_Click"></asp:Button>
</td>
<td>
<asp:CheckBox ID="chkInherit" runat="server" meta:resourcekey="chkInherit" Text="Services inherit Login Name" checked="true"/>
</td>
</tr>
<tr>
@ -62,8 +70,13 @@
<tr>
<td class="FormLabel150" valign="top"><asp:Localize ID="locPassword" runat="server" meta:resourcekey="locPassword" Text="Password:"></asp:Localize></td>
<td>
<wsp:PasswordControl id="password" runat="server" ValidationGroup="EditMailbox">
<wsp:PasswordControl id="password" runat="server" ValidationGroup="ValidatePassword">
</wsp:PasswordControl>
</td>
<td>
<asp:Button id="btnSetUserPassword" runat="server" Text="Set Password" CssClass="Button1"
meta:resourcekey="btnSetUserPassword" OnClick="btnSetUserPassword_Click" ValidationGroup="ValidatePassword"></asp:Button>
<asp:ValidationSummary ID="ValidationSummary2" runat="server" ShowMessageBox="True" ShowSummary="False" ValidationGroup="ValidatePassword" />
</td>
</tr>
@ -71,9 +84,6 @@
<tr>
<td></td>
<td>
<asp:CheckBox ID="chkSetPassword" runat="server"
meta:resourcekey="chkSetPassword" Text="Set Password"
oncheckedchanged="chkSetPassword_CheckedChanged" AutoPostBack="True" />
<br />
<asp:CheckBox ID="chkDisable" runat="server" meta:resourcekey="chkDisable" Text="Disable User" />
<br />
@ -107,7 +117,7 @@
</table>
<wsp:CollapsiblePanel id="secCompanyInfo" runat="server"
<wsp:CollapsiblePanel id="secCompanyInfo" runat="server" IsCollapsed="true"
TargetControlID="CompanyInfo" meta:resourcekey="secCompanyInfo" Text="Company Information">
</wsp:CollapsiblePanel>
<asp:Panel ID="CompanyInfo" runat="server" Height="0" style="overflow:hidden;">
@ -146,7 +156,7 @@
</asp:Panel>
<wsp:CollapsiblePanel id="secContactInfo" runat="server"
<wsp:CollapsiblePanel id="secContactInfo" runat="server" IsCollapsed="true"
TargetControlID="ContactInfo" meta:resourcekey="secContactInfo" Text="Contact Information">
</wsp:CollapsiblePanel>
@ -191,7 +201,7 @@
</table>
</asp:Panel>
<wsp:CollapsiblePanel id="secAddressInfo" runat="server"
<wsp:CollapsiblePanel id="secAddressInfo" runat="server" IsCollapsed="true"
TargetControlID="AddressInfo" meta:resourcekey="secAddressInfo" Text="Address">
</wsp:CollapsiblePanel>
<asp:Panel ID="AddressInfo" runat="server" Height="0" style="overflow:hidden;">
@ -239,7 +249,7 @@
</table>
<wsp:CollapsiblePanel id="secAdvanced" runat="server"
<wsp:CollapsiblePanel id="secAdvanced" runat="server" IsCollapsed="true"
TargetControlID="AdvancedInfo" meta:resourcekey="secAdvanced" Text="Advanced">
</wsp:CollapsiblePanel>

View file

@ -27,6 +27,7 @@
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Web.UI.WebControls;
using WebsitePanel.EnterpriseServer;
using WebsitePanel.Providers.HostedSolution;
using WebsitePanel.Providers.ResultObjects;
@ -63,8 +64,6 @@ namespace WebsitePanel.Portal.HostedSolution
}
}
password.EditMode = password.ValidationEnabled = false;
// get settings
OrganizationUser user = ES.Services.Organizations.GetUserGeneralSettings(PanelRequest.ItemID,
PanelRequest.AccountID);
@ -127,19 +126,54 @@ namespace WebsitePanel.Portal.HostedSolution
{
lblUserPrincipalName.Visible = true;
upn.Visible = false;
ddlEmailAddresses.Visible = false;
btnSetUserPrincipalName.Visible = false;
chkInherit.Visible = false;
}
else
{
lblUserPrincipalName.Visible = false;
upn.Visible = true;
if (!string.IsNullOrEmpty(user.UserPrincipalName))
upn.Visible = false;
ddlEmailAddresses.Visible = false;
btnSetUserPrincipalName.Visible = true;
chkInherit.Visible = true;
if (user.AccountType == ExchangeAccountType.Mailbox)
{
string[] Tmp = user.UserPrincipalName.Split('@');
upn.AccountName = Tmp[0];
ddlEmailAddresses.Visible = true;
WebsitePanel.EnterpriseServer.ExchangeEmailAddress[] emails = ES.Services.ExchangeServer.GetMailboxEmailAddresses(PanelRequest.ItemID, PanelRequest.AccountID);
if (Tmp.Length > 1)
foreach (WebsitePanel.EnterpriseServer.ExchangeEmailAddress mail in emails)
{
upn.DomainName = Tmp[1];
ListItem li = new ListItem();
li.Text = mail.EmailAddress;
li.Value = mail.EmailAddress;
li.Selected = mail.IsPrimary;
ddlEmailAddresses.Items.Add(li);
}
foreach (ListItem li in ddlEmailAddresses.Items)
{
if (li.Value == user.UserPrincipalName)
{
ddlEmailAddresses.ClearSelection();
li.Selected = true;
break;
}
}
}
else
{
upn.Visible = true;
if (!string.IsNullOrEmpty(user.UserPrincipalName))
{
string[] Tmp = user.UserPrincipalName.Split('@');
upn.AccountName = Tmp[0];
if (Tmp.Length > 1)
{
upn.DomainName = Tmp[1];
}
}
}
@ -153,6 +187,8 @@ namespace WebsitePanel.Portal.HostedSolution
chkLocked.Checked = user.Locked;
password.ValidationEnabled = true;
password.Password = string.Empty;
}
catch (Exception ex)
{
@ -165,17 +201,12 @@ namespace WebsitePanel.Portal.HostedSolution
if (!Page.IsValid)
return;
string pwd = password.Password;
if (!chkSetPassword.Checked)
pwd = string.Empty;
try
{
int result = ES.Services.Organizations.SetUserGeneralSettings(
PanelRequest.ItemID, PanelRequest.AccountID,
txtDisplayName.Text,
pwd,
string.Empty,
false,
chkDisable.Checked,
chkLocked.Checked,
@ -230,10 +261,66 @@ namespace WebsitePanel.Portal.HostedSolution
SaveSettings();
}
protected void chkSetPassword_CheckedChanged(object sender, EventArgs e)
protected void btnSetUserPrincipalName_Click(object sender, EventArgs e)
{
password.EditMode = password.ValidationEnabled = chkSetPassword.Checked;
string userPrincipalName = string.Empty;
if (upn.Visible)
userPrincipalName = upn.Email;
else
if (ddlEmailAddresses.Visible)
userPrincipalName = (string)ddlEmailAddresses.SelectedValue;
if (string.IsNullOrEmpty(userPrincipalName)) return;
try
{
int result = ES.Services.Organizations.SetUserPrincipalName(
PanelRequest.ItemID, PanelRequest.AccountID,
userPrincipalName.ToLower(),
chkInherit.Checked);
if (result < 0)
{
messageBox.ShowResultMessage(result);
return;
}
messageBox.ShowSuccessMessage("ORGANIZATION_SET_USER_PRINCIPALNAME");
}
catch (Exception ex)
{
messageBox.ShowErrorMessage("ORGANIZATION_SET_USER_PRINCIPALNAME", ex);
}
}
protected void btnSetUserPassword_Click(object sender, EventArgs e)
{
if (!Page.IsValid)
return;
try
{
int result = ES.Services.Organizations.SetUserPassword(
PanelRequest.ItemID, PanelRequest.AccountID,
password.Password);
if (result < 0)
{
messageBox.ShowResultMessage(result);
return;
}
messageBox.ShowSuccessMessage("ORGANIZATION_SET_USER_PASSWORD");
}
catch (Exception ex)
{
messageBox.ShowErrorMessage("ORGANIZATION_SET_USER_PASSWORD", ex);
}
}
}

View file

@ -120,6 +120,33 @@ namespace WebsitePanel.Portal.HostedSolution {
/// </remarks>
protected global::WebsitePanel.Portal.ExchangeServer.UserControls.EmailAddress upn;
/// <summary>
/// ddlEmailAddresses 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.DropDownList ddlEmailAddresses;
/// <summary>
/// btnSetUserPrincipalName 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.Button btnSetUserPrincipalName;
/// <summary>
/// chkInherit 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 chkInherit;
/// <summary>
/// locDisplayName control.
/// </summary>
@ -166,13 +193,22 @@ namespace WebsitePanel.Portal.HostedSolution {
protected global::WebsitePanel.Portal.PasswordControl password;
/// <summary>
/// chkSetPassword control.
/// btnSetUserPassword 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 chkSetPassword;
protected global::System.Web.UI.WebControls.Button btnSetUserPassword;
/// <summary>
/// ValidationSummary2 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.ValidationSummary ValidationSummary2;
/// <summary>
/// chkDisable control.