This commit is contained in:
Virtuworks 2013-04-02 19:04:16 -04:00
commit d27d5b5835
14 changed files with 641 additions and 37 deletions

View file

@ -62,6 +62,8 @@ namespace WebsitePanel.EnterpriseServer.HostedSolution {
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ResultObject))]
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ServiceProviderItem))]
public partial class esOrganizations : Microsoft.Web.Services3.WebServicesClientProtocol {
private System.Threading.SendOrPostCallback CheckOrgIdExistsOperationCompleted;
private System.Threading.SendOrPostCallback CreateOrganizationOperationCompleted;
@ -117,6 +119,9 @@ namespace WebsitePanel.EnterpriseServer.HostedSolution {
public esOrganizations() {
this.Url = "http://localhost:9002/esOrganizations.asmx";
}
/// <remarks/>
public event CheckOrgIdExistsCompletedEventHandler CheckOrgIdExistsCompleted;
/// <remarks/>
public event CreateOrganizationCompletedEventHandler CreateOrganizationCompleted;
@ -192,6 +197,55 @@ namespace WebsitePanel.EnterpriseServer.HostedSolution {
/// <remarks/>
public event GetPasswordPolicyCompletedEventHandler GetPasswordPolicyCompleted;
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/CheckOrgIdExists", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public bool CheckOrgIdExists(string orgId)
{
object[] results = this.Invoke("CheckOrgIdExists", new object[] {
orgId});
return ((bool)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginCheckOrgIdExists(string orgId, System.AsyncCallback callback, object asyncState)
{
return this.BeginInvoke("CheckOrgIdExists", new object[] {
orgId}, callback, asyncState);
}
/// <remarks/>
public bool EndCheckOrgIdExists(System.IAsyncResult asyncResult)
{
object[] results = this.EndInvoke(asyncResult);
return ((bool)(results[0]));
}
/// <remarks/>
public void CheckOrgIdExistsAsync(string orgId)
{
this.CheckOrgIdExistsAsync(orgId, null);
}
/// <remarks/>
public void CheckOrgIdExistsAsync(string orgId, object userState)
{
if ((this.CheckOrgIdExistsOperationCompleted == null))
{
this.CheckOrgIdExistsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCheckOrgIdExistsOperationCompleted);
}
this.InvokeAsync("CheckOrgIdExists", new object[] {
orgId}, this.CheckOrgIdExistsOperationCompleted, userState);
}
private void OnCheckOrgIdExistsOperationCompleted(object arg)
{
if ((this.CheckOrgIdExistsCompleted != null))
{
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.CheckOrgIdExistsCompleted(this, new CheckOrgIdExistsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
}
}
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/CreateOrganization", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
@ -204,6 +258,8 @@ namespace WebsitePanel.EnterpriseServer.HostedSolution {
return ((int)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginCreateOrganization(int packageId, string organizationID, string organizationName, string domainName, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("CreateOrganization", new object[] {
@ -1585,6 +1641,36 @@ namespace WebsitePanel.EnterpriseServer.HostedSolution {
base.CancelAsync(userState);
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.17929")]
public delegate void CheckOrgIdExistsCompletedEventHandler(object sender, CheckOrgIdExistsCompletedEventArgs e);
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.17929")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class CheckOrgIdExistsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
{
private object[] results;
internal CheckOrgIdExistsCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState)
{
this.results = results;
}
/// <remarks/>
public bool Result
{
get
{
this.RaiseExceptionIfNecessary();
return ((bool)(this.results[0]));
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]

View file

@ -265,7 +265,7 @@ namespace WebsitePanel.EnterpriseServer
return itemId;
}
private static bool OrganizationIdentifierExists(string organizationId)
public static bool OrganizationIdentifierExists(string organizationId)
{
return DataProvider.ExchangeOrganizationExists(organizationId);
}

View file

@ -45,6 +45,12 @@ namespace WebsitePanel.EnterpriseServer
{
#region Organizations
[WebMethod]
public bool CheckOrgIdExists(string orgId)
{
return OrganizationController.OrganizationIdentifierExists(orgId);
}
[WebMethod]
public int CreateOrganization(int packageId, string organizationID, string organizationName, string domainName)
{

View file

@ -120,4 +120,7 @@
<data name="secMailboxPassword.Text" xml:space="preserve">
<value>User Password Policy</value>
</data>
<data name="secOrg.Text" xml:space="preserve">
<value>Organization Id Policy</value>
</data>
</root>

View file

@ -27,8 +27,6 @@
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Data;
using System.Text;
using System.Collections.Generic;
using WebsitePanel.EnterpriseServer;
using WebsitePanel.Providers.HostedSolution;
@ -39,18 +37,19 @@ namespace WebsitePanel.Portal.ExchangeServer
{
protected void Page_Load(object sender, EventArgs e)
{
DomainInfo[] domains = ES.Services.Servers.GetMyDomains(PanelSecurity.PackageId);
Organization[] orgs = ES.Services.Organizations.GetOrganizations(PanelSecurity.PackageId, false);
List<OrganizationDomainName> list = new List<OrganizationDomainName>();
var list = new List<OrganizationDomainName>();
SetPolicy(PanelSecurity.PackageId, UserSettings.EXCHANGE_POLICY, "OrgIdPolicy");
foreach (Organization o in orgs)
{
OrganizationDomainName[] tmpList = ES.Services.Organizations.GetOrganizationDomains(o.Id);
foreach (OrganizationDomainName name in tmpList) list.Add(name);
foreach (OrganizationDomainName name in tmpList)
{
list.Add(name);
}
}
foreach (DomainInfo d in domains)
@ -65,9 +64,11 @@ namespace WebsitePanel.Portal.ExchangeServer
bAdd = false;
break;
}
}
if (bAdd) ddlDomains.Items.Add(d.DomainName.ToLower());
if (bAdd)
{
ddlDomains.Items.Add(d.DomainName.ToLower());
}
}
}
@ -77,6 +78,50 @@ namespace WebsitePanel.Portal.ExchangeServer
}
}
public void SetPolicy(int packageId, string settingsName, string key)
{
PackageInfo package = PackagesHelper.GetCachedPackage(packageId);
if (package != null)
{
SetOrgIdPolicy(package.UserId, settingsName, key);
}
}
public void SetOrgIdPolicy(int userId, string settingsName, string key)
{
UserInfo user = UsersHelper.GetCachedUser(userId);
if (user != null)
{
UserSettings settings = ES.Services.Users.GetUserSettings(userId, settingsName);
if (settings != null && settings["OrgIdPolicy"] != null)
{
SetOrgIdPolicy(settings);
}
}
}
private void SetOrgIdPolicy(UserSettings settings)
{
string policyValue = settings["OrgIdPolicy"];
string[] values = policyValue.Split(';');
if (values.Length > 1 && Convert.ToBoolean(values[0]))
{
try
{
int maxLength = Convert.ToInt32(values[1]);
txtOrganizationID.MaxLength = maxLength;
valRequireCorrectOrgID.ValidationExpression = string.Format("[a-zA-Z0-9.-]{{1,{0}}}", maxLength);
}
catch (Exception)
{
}
}
}
protected void btnCreate_Click(object sender, EventArgs e)
{
CreateOrganization();
@ -85,14 +130,13 @@ namespace WebsitePanel.Portal.ExchangeServer
private void CreateOrganization()
{
if (!Page.IsValid)
{
return;
}
try
{
int itemId = ES.Services.Organizations.CreateOrganization(PanelSecurity.PackageId,
txtOrganizationID.Text.Trim().ToLower(), txtOrganizationName.Text.Trim().ToLower(),
ddlDomains.SelectedValue.Trim().ToLower());
int itemId = ES.Services.Organizations.CreateOrganization(PanelSecurity.PackageId, txtOrganizationID.Text.Trim().ToLower(), txtOrganizationName.Text.Trim().ToLower(), ddlDomains.SelectedValue.Trim().ToLower());
if (itemId < 0)
{
@ -100,9 +144,7 @@ namespace WebsitePanel.Portal.ExchangeServer
return;
}
Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "organization_home",
"ItemID=" + itemId));
Response.Redirect(EditUrl("SpaceID", PanelSecurity.PackageId.ToString(), "organization_home", "ItemID=" + itemId));
}
catch (Exception ex)
{

View file

@ -1,5 +1,6 @@
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SettingsExchangePolicy.ascx.cs" Inherits="WebsitePanel.Portal.SettingsExchangePolicy" %>
<%@ Register Src="UserControls/PasswordPolicyEditor.ascx" TagName="PasswordPolicyEditor" TagPrefix="wsp" %>
<%@ Register Src="UserControls/OrgIdPolicyEditor.ascx" TagName="OrgIdPolicyEditor" TagPrefix="wsp" %>
<%@ Register TagPrefix="wsp" TagName="CollapsiblePanel" Src="UserControls/CollapsiblePanel.ascx" %>
<wsp:CollapsiblePanel id="secMailboxPassword" runat="server"
@ -15,4 +16,17 @@
</td>
</tr>
</table>
</asp:Panel>
<wsp:CollapsiblePanel id="secOrg" runat="server" TargetControlID="OrgIdPanel" meta:resourcekey="secOrg" Text="Organization Id Policy"/>
<asp:Panel ID="OrgIdPanel" runat="server" Height="0" style="overflow:hidden;">
<table>
<tr>
<td class="SubHead" width="150" nowrap>
</td>
<td>
<wsp:OrgIdPolicyEditor id="orgIdPolicy" runat="server" />
</td>
</tr>
</table>
</asp:Panel>

View file

@ -26,33 +26,27 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using WebsitePanel.EnterpriseServer;
namespace WebsitePanel.Portal
{
public partial class SettingsExchangePolicy : WebsitePanelControlBase, IUserSettingsEditorControl
public partial class SettingsExchangePolicy : WebsitePanelControlBase, IUserSettingsEditorControl
{
#region IUserSettingsEditorControl Members
public void BindSettings(UserSettings settings)
{
// mailbox
mailboxPasswordPolicy.Value = settings["MailboxPasswordPolicy"];
mailboxPasswordPolicy.Value = settings["MailboxPasswordPolicy"];
orgIdPolicy.Value = settings["OrgIdPolicy"];
}
public void SaveSettings(UserSettings settings)
{
// mailbox
settings["MailboxPasswordPolicy"] = mailboxPasswordPolicy.Value;
settings["MailboxPasswordPolicy"] = mailboxPasswordPolicy.Value;
settings["OrgIdPolicy"] = orgIdPolicy.Value;
}
}
#endregion
}
}

View file

@ -1,10 +1,37 @@
// Copyright (c) 2012, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.1433
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
@ -39,5 +66,32 @@ namespace WebsitePanel.Portal {
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::WebsitePanel.Portal.PasswordPolicyEditor mailboxPasswordPolicy;
/// <summary>
/// secOrg control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::WebsitePanel.Portal.CollapsiblePanel secOrg;
/// <summary>
/// OrgIdPanel 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.Panel OrgIdPanel;
/// <summary>
/// orgIdPolicy control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::WebsitePanel.Portal.UserControls.OrgIdPolicyEditor orgIdPolicy;
}
}

View file

@ -0,0 +1,132 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="enablePolicyCheckBox.Text" xml:space="preserve">
<value>Enable Policy</value>
</data>
<data name="lblMaximumLength.Text" xml:space="preserve">
<value>Maximum OrgId length:</value>
</data>
<data name="valCorrectMaxLength.Text" xml:space="preserve">
<value>*</value>
</data>
<data name="valRequireMaxLength.Text" xml:space="preserve">
<value>*</value>
</data>
</root>

View file

@ -0,0 +1,18 @@
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="OrgIdPolicyEditor.ascx.cs" Inherits="WebsitePanel.Portal.UserControls.OrgIdPolicyEditor" %>
<asp:UpdatePanel runat="server" ID="OrgIdPolicyPanel" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:CheckBox id="enablePolicyCheckBox" runat="server" meta:resourcekey="enablePolicyCheckBox" Text="Enable Policy" CssClass="NormalBold" AutoPostBack="true" OnCheckedChanged="EnablePolicy_CheckedChanged"/>
<table id="PolicyTable" runat="server" cellpadding="2">
<tr>
<td class="Normal" style="width:150px;">
<asp:Label ID="lblMaximumLength" runat="server" meta:resourcekey="lblMaximumLength" Text="Maximum OrgId length:"/>
</td>
<td class="Normal">
<asp:TextBox ID="txtMaximumLength" runat="server" CssClass="NormalTextBox" Width="40px"/>
<asp:RequiredFieldValidator ID="valRequireMaxLength" runat="server" ControlToValidate="txtMaximumLength" meta:resourcekey="valRequireMaxLength" ErrorMessage="*" ValidationGroup="SettingsEditor" Display="Dynamic"/>
<asp:RegularExpressionValidator ID="valCorrectMaxLength" runat="server" ControlToValidate="txtMaximumLength" meta:resourcekey="valCorrectMaxLength" Display="Dynamic" ErrorMessage="*" ValidationExpression="\d{1,3}" ValidationGroup="SettingsEditor"/>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>

View file

@ -0,0 +1,97 @@
// Copyright (c) 2012, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Text;
using System.Web.UI;
namespace WebsitePanel.Portal.UserControls
{
public partial class OrgIdPolicyEditor : UserControl
{
#region Properties
public string Value
{
get
{
var sb = new StringBuilder();
sb.Append(enablePolicyCheckBox.Checked.ToString()).Append(";");
sb.Append(txtMaximumLength.Text).Append(";");
return sb.ToString();
}
set
{
if (String.IsNullOrEmpty(value))
{
enablePolicyCheckBox.Checked = true;
txtMaximumLength.Text = "128";
}
else
{
try
{
string[] parts = value.Split(';');
enablePolicyCheckBox.Checked = Utils.ParseBool(parts[0], false);
txtMaximumLength.Text = parts[1];
}
catch
{
}
}
ToggleControls();
}
}
#endregion
#region Methods
protected void Page_Load(object sender, EventArgs e)
{
}
private void ToggleControls()
{
PolicyTable.Visible = enablePolicyCheckBox.Checked;
}
#endregion
#region Event Handlers
protected void EnablePolicy_CheckedChanged(object sender, EventArgs e)
{
ToggleControls();
}
#endregion
}
}

View file

@ -0,0 +1,106 @@
// Copyright (c) 2012, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace WebsitePanel.Portal.UserControls {
public partial class OrgIdPolicyEditor {
/// <summary>
/// OrgIdPolicyPanel control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.UpdatePanel OrgIdPolicyPanel;
/// <summary>
/// enablePolicyCheckBox 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 enablePolicyCheckBox;
/// <summary>
/// PolicyTable control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlTable PolicyTable;
/// <summary>
/// lblMaximumLength 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 lblMaximumLength;
/// <summary>
/// txtMaximumLength 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.TextBox txtMaximumLength;
/// <summary>
/// valRequireMaxLength 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.RequiredFieldValidator valRequireMaxLength;
/// <summary>
/// valCorrectMaxLength 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.RegularExpressionValidator valCorrectMaxLength;
}
}

View file

@ -27,8 +27,11 @@
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI.WebControls;
using WebsitePanel.EnterpriseServer;
using WebsitePanel.Providers.HostedSolution;
namespace WebsitePanel.Portal
{
@ -173,11 +176,18 @@ namespace WebsitePanel.Portal
UserInfo user = UsersHelper.GetUser(PanelSecurity.SelectedUserId);
if (user != null)
{
{
if (user.Role != UserRole.Reseller)
{
UserSettings settings = ES.Services.Users.GetUserSettings(user.UserId, UserSettings.EXCHANGE_POLICY);
string orgId = domainName.ToLower();
ES.Services.Organizations.CreateOrganization(result.Result, domainName.ToLower(), domainName.ToLower(), domainName.ToLower());
if (settings != null && settings["OrgIdPolicy"] != null)
{
orgId = GetOrgId(settings["OrgIdPolicy"], domainName, result.Result);
}
ES.Services.Organizations.CreateOrganization(result.Result, orgId, domainName.ToLower(), domainName.ToLower());
if (result.Result < 0)
{
@ -199,6 +209,39 @@ namespace WebsitePanel.Portal
Response.Redirect(PortalUtils.GetSpaceHomePageUrl(result.Result));
}
private string GetOrgId(string orgIdPolicy, string domainName, int packageId)
{
string[] values = orgIdPolicy.Split(';');
if (values.Length > 1 && Convert.ToBoolean(values[0]))
{
try
{
int maxLength = Convert.ToInt32(values[1]);
if (domainName.Length > maxLength)
{
domainName = domainName.Substring(0, maxLength);
string orgId = domainName;
int counter = 0;
while (ES.Services.Organizations.CheckOrgIdExists(orgId))
{
counter++;
orgId = maxLength > 3 ? string.Format("{0}{1}", orgId.Substring(0, orgId.Length - 3), counter.ToString("d3")) : counter.ToString("d3");
}
return orgId;
}
}
catch (Exception)
{
}
}
return domainName;
}
protected void ddlPlans_SelectedIndexChanged(object sender, EventArgs e)
{
BindHostingPlan();

View file

@ -419,6 +419,13 @@
<Compile Include="UserControls\EditFeedsList.ascx.designer.cs">
<DependentUpon>EditFeedsList.ascx</DependentUpon>
</Compile>
<Compile Include="UserControls\OrgIdPolicyEditor.ascx.cs">
<DependentUpon>OrgIdPolicyEditor.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="UserControls\OrgIdPolicyEditor.ascx.designer.cs">
<DependentUpon>OrgIdPolicyEditor.ascx</DependentUpon>
</Compile>
<Compile Include="VPSForPC\MonitoringPage.aspx.cs">
<DependentUpon>MonitoringPage.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
@ -3870,6 +3877,7 @@
<Content Include="SettingsExchangeMailboxPlansPolicy.ascx" />
<Content Include="SettingsLyncUserPlansPolicy.ascx" />
<Content Include="UserControls\EditFeedsList.ascx" />
<Content Include="UserControls\OrgIdPolicyEditor.ascx" />
<Content Include="VPSForPC\MonitoringPage.aspx" />
<Content Include="VPSForPC\VdcAccountVLanAdd.ascx" />
<Content Include="VPSForPC\VdcAccountVLanNetwork.ascx" />
@ -5010,6 +5018,7 @@
<Content Include="ExchangeServer\App_LocalResources\OrganizationAddDomainName.ascx.resx">
<SubType>Designer</SubType>
</Content>
<Content Include="UserControls\App_LocalResources\OrgIdPolicyEditor.ascx.resx" />
<None Include="Resources\Windows2008_Settings.ascx.resx" />
<Content Include="App_LocalResources\WebSitesHeliconZooControl.ascx.resx" />
<EmbeddedResource Include="UserControls\App_LocalResources\EditDomainsList.ascx.resx">