Check OrgId policy while adding hosted organization
if "Automated Hosted Organization" checked on.
This commit is contained in:
parent
306e3147eb
commit
252d518537
4 changed files with 138 additions and 3 deletions
|
@ -62,6 +62,8 @@ namespace WebsitePanel.EnterpriseServer.HostedSolution {
|
||||||
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ResultObject))]
|
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ResultObject))]
|
||||||
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ServiceProviderItem))]
|
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ServiceProviderItem))]
|
||||||
public partial class esOrganizations : Microsoft.Web.Services3.WebServicesClientProtocol {
|
public partial class esOrganizations : Microsoft.Web.Services3.WebServicesClientProtocol {
|
||||||
|
|
||||||
|
private System.Threading.SendOrPostCallback CheckOrgIdExistsOperationCompleted;
|
||||||
|
|
||||||
private System.Threading.SendOrPostCallback CreateOrganizationOperationCompleted;
|
private System.Threading.SendOrPostCallback CreateOrganizationOperationCompleted;
|
||||||
|
|
||||||
|
@ -117,6 +119,9 @@ namespace WebsitePanel.EnterpriseServer.HostedSolution {
|
||||||
public esOrganizations() {
|
public esOrganizations() {
|
||||||
this.Url = "http://localhost:9002/esOrganizations.asmx";
|
this.Url = "http://localhost:9002/esOrganizations.asmx";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <remarks/>
|
||||||
|
public event CheckOrgIdExistsCompletedEventHandler CheckOrgIdExistsCompleted;
|
||||||
|
|
||||||
/// <remarks/>
|
/// <remarks/>
|
||||||
public event CreateOrganizationCompletedEventHandler CreateOrganizationCompleted;
|
public event CreateOrganizationCompletedEventHandler CreateOrganizationCompleted;
|
||||||
|
@ -192,6 +197,55 @@ namespace WebsitePanel.EnterpriseServer.HostedSolution {
|
||||||
|
|
||||||
/// <remarks/>
|
/// <remarks/>
|
||||||
public event GetPasswordPolicyCompletedEventHandler GetPasswordPolicyCompleted;
|
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/>
|
/// <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)]
|
[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]));
|
return ((int)(results[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <remarks/>
|
/// <remarks/>
|
||||||
public System.IAsyncResult BeginCreateOrganization(int packageId, string organizationID, string organizationName, string domainName, System.AsyncCallback callback, object asyncState) {
|
public System.IAsyncResult BeginCreateOrganization(int packageId, string organizationID, string organizationName, string domainName, System.AsyncCallback callback, object asyncState) {
|
||||||
return this.BeginInvoke("CreateOrganization", new object[] {
|
return this.BeginInvoke("CreateOrganization", new object[] {
|
||||||
|
@ -1585,6 +1641,36 @@ namespace WebsitePanel.EnterpriseServer.HostedSolution {
|
||||||
base.CancelAsync(userState);
|
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/>
|
/// <remarks/>
|
||||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
|
||||||
|
|
|
@ -265,7 +265,7 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
return itemId;
|
return itemId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool OrganizationIdentifierExists(string organizationId)
|
public static bool OrganizationIdentifierExists(string organizationId)
|
||||||
{
|
{
|
||||||
return DataProvider.ExchangeOrganizationExists(organizationId);
|
return DataProvider.ExchangeOrganizationExists(organizationId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,12 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
{
|
{
|
||||||
#region Organizations
|
#region Organizations
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public bool CheckOrgIdExists(string orgId)
|
||||||
|
{
|
||||||
|
return OrganizationController.OrganizationIdentifierExists(orgId);
|
||||||
|
}
|
||||||
|
|
||||||
[WebMethod]
|
[WebMethod]
|
||||||
public int CreateOrganization(int packageId, string organizationID, string organizationName, string domainName)
|
public int CreateOrganization(int packageId, string organizationID, string organizationName, string domainName)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,8 +27,11 @@
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Web.UI.WebControls;
|
using System.Web.UI.WebControls;
|
||||||
using WebsitePanel.EnterpriseServer;
|
using WebsitePanel.EnterpriseServer;
|
||||||
|
using WebsitePanel.Providers.HostedSolution;
|
||||||
|
|
||||||
namespace WebsitePanel.Portal
|
namespace WebsitePanel.Portal
|
||||||
{
|
{
|
||||||
|
@ -173,11 +176,18 @@ namespace WebsitePanel.Portal
|
||||||
UserInfo user = UsersHelper.GetUser(PanelSecurity.SelectedUserId);
|
UserInfo user = UsersHelper.GetUser(PanelSecurity.SelectedUserId);
|
||||||
|
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
if (user.Role != UserRole.Reseller)
|
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)
|
if (result.Result < 0)
|
||||||
{
|
{
|
||||||
|
@ -199,6 +209,39 @@ namespace WebsitePanel.Portal
|
||||||
Response.Redirect(PortalUtils.GetSpaceHomePageUrl(result.Result));
|
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)
|
protected void ddlPlans_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
BindHostingPlan();
|
BindHostingPlan();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue