diff --git a/WebsitePanel/Database/update_db.sql b/WebsitePanel/Database/update_db.sql index 88287608..72239832 100644 --- a/WebsitePanel/Database/update_db.sql +++ b/WebsitePanel/Database/update_db.sql @@ -12,6 +12,20 @@ BEGIN END GO + +--- Fix on version 2.0 +DELETE FROM HostingPlanQuotas WHERE QuotaID = 340 +GO +DELETE FROM HostingPlanQuotas WHERE QuotaID = 341 +GO +DELETE FROM HostingPlanQuotas WHERE QuotaID = 342 +GO +DELETE FROM HostingPlanQuotas WHERE QuotaID = 343 +GO +DELETE FROM HostingPlanResources WHERE GroupID = 33 +GO + + -- Version 2.1 section IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [DisplayName] = 'Hosted Microsoft Exchange Server 2013') BEGIN @@ -25,16 +39,6 @@ GO IF NOT EXISTS (SELECT * FROM [dbo].[Quotas] WHERE [QuotaName] = 'Exchange2007.AllowLitigationHold') -DELETE FROM HostingPlanQuotas WHERE QuotaID = 340 -GO -DELETE FROM HostingPlanQuotas WHERE QuotaID = 341 -GO -DELETE FROM HostingPlanQuotas WHERE QuotaID = 342 -GO -DELETE FROM HostingPlanQuotas WHERE QuotaID = 343 -GO -DELETE FROM HostingPlanResources WHERE GroupID = 33 -GO BEGIN INSERT [dbo].[Quotas] ([QuotaID], [GroupID],[QuotaOrder], [QuotaName], [QuotaDescription], [QuotaTypeID], [ServiceQuota], [ItemTypeID]) VALUES (420, 12, 24,N'Exchange2007.AllowLitigationHold',N'Allow Litigation Hold',1, 0 , NULL) END @@ -315,4 +319,10 @@ exec sp_xml_removedocument @idoc COMMIT TRAN RETURN -GO \ No newline at end of file +GO + +IF NOT EXISTS (SELECT * FROM [dbo].[Providers] WHERE [DisplayName] = 'Hosted MS CRM 2011') +BEGIN +INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (1201, 21, N'CRM', N'Hosted MS CRM 2011', N'WebsitePanel.Providers.HostedSolution.CRMProvider2011, WebsitePanel.Providers.HostedSolution', N'CRM', NULL) +END +GO diff --git a/WebsitePanel/Database/update_db_crm2011.sql b/WebsitePanel/Database/update_db_crm2011.sql deleted file mode 100644 index bc72f02c..00000000 --- a/WebsitePanel/Database/update_db_crm2011.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT [dbo].[Providers] ([ProviderID], [GroupID], [ProviderName], [DisplayName], [ProviderType], [EditorControl], [DisableAutoDiscovery]) VALUES (1201, 21, N'CRM', N'Hosted MS CRM 2011', N'WebsitePanel.Providers.HostedSolution.CRMProvider2011, WebsitePanel.Providers.HostedSolution', N'CRM', NULL) -GO diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/OrganizationController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/OrganizationController.cs index ef2994d8..4ab73171 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/OrganizationController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/HostedSolution/OrganizationController.cs @@ -1329,7 +1329,7 @@ namespace WebsitePanel.EnterpriseServer Organizations orgProxy = GetOrganizationProxy(org.ServiceId); string upn = string.Format("{0}@{1}", name, domain); - string sAMAccountName = BuildAccountName(org.OrganizationId, name); + string sAMAccountName = BuildAccountName(org.OrganizationId, name, org.ServiceId); TaskManager.Write("accountName :" + sAMAccountName); TaskManager.Write("upn :" + upn); @@ -1454,21 +1454,21 @@ namespace WebsitePanel.EnterpriseServer { DataProvider.AddExchangeAccountEmailAddress(accountId, emailAddress); } - - private static string BuildAccountName(string orgId, string name) + + private static string BuildAccountName(string orgId, string name, int ServiceId) { string accountName = name = name.Replace(" ", ""); string CounterStr = "00000"; int counter = 0; bool bFound = false; - if (!AccountExists(accountName)) return accountName; + if (!AccountExists(accountName, ServiceId)) return accountName; do { accountName = genSamLogin(name, CounterStr); - if (!AccountExists(accountName)) bFound = true; + if (!AccountExists(accountName, ServiceId)) bFound = true; CounterStr = counter.ToString("d5"); counter++; @@ -1494,9 +1494,19 @@ namespace WebsitePanel.EnterpriseServer } - private static bool AccountExists(string accountName) + private static bool AccountExists(string accountName, int ServiceId) { - return DataProvider.ExchangeAccountExists(accountName); + + if (!DataProvider.ExchangeAccountExists(accountName)) + { + Organizations orgProxy = GetOrganizationProxy(ServiceId); + + + return orgProxy.DoesSamAccountNameExist(accountName); + } + else + return true; + } public static int DeleteUser(int itemId, int accountId) diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/IOrganization.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/IOrganization.cs index 09e1a3de..6da1e71a 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/IOrganization.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/IOrganization.cs @@ -64,5 +64,7 @@ namespace WebsitePanel.Providers.HostedSolution PasswordPolicyResult GetPasswordPolicy(); string GetSamAccountNameByUserPrincipalName(string organizationId, string userPrincipalName); + + bool DoesSamAccountNameExist(string accountName); } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs index 9dee569f..7b6e84fb 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs @@ -710,6 +710,52 @@ namespace WebsitePanel.Providers.HostedSolution } + public bool DoesSamAccountNameExist(string accountName) + { + return DoesSamAccountNameExistInternal(accountName); + } + + + private bool DoesSamAccountNameExistInternal(string accountName) + { + HostedSolutionLog.LogStart("DoesSamAccountNameExistInternal"); + HostedSolutionLog.DebugInfo("userPrincipalName : {0}", accountName); + bool bFound = false; + + try + { + + string path = GetRootOU(); + DirectoryEntry entry = ActiveDirectoryUtils.GetADObject(path); + + DirectorySearcher searcher = new DirectorySearcher(entry); + searcher.PropertiesToLoad.Add("sAMAccountName"); + searcher.Filter = "(sAMAccountName=" + accountName + ")"; + searcher.SearchScope = SearchScope.Subtree; + + SearchResult resCollection = searcher.FindOne(); + if (resCollection != null) + { + if(resCollection.Properties["samaccountname"] != null) + bFound = true; ; + } + + HostedSolutionLog.LogEnd("GetSamAccountNameByUserPrincipalNameInternal"); + } + catch (Exception e) + { + HostedSolutionLog.DebugInfo("Failed : {0}", e.Message); + } + + return bFound; + + + + return false; + } + + + #endregion #region Domains diff --git a/WebsitePanel/Sources/WebsitePanel.Server.Client/OrganizationProxy.cs b/WebsitePanel/Sources/WebsitePanel.Server.Client/OrganizationProxy.cs index f7ecb33e..f9ec5034 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server.Client/OrganizationProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server.Client/OrganizationProxy.cs @@ -26,7 +26,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - //------------------------------------------------------------------------------ // // This code was generated by a tool. @@ -48,11 +47,11 @@ namespace WebsitePanel.Providers.HostedSolution { using System; using System.Diagnostics; - using WebsitePanel.Providers.Common; using WebsitePanel.Providers.ResultObjects; - + + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] [System.Diagnostics.DebuggerStepThroughAttribute()] @@ -90,6 +89,8 @@ namespace WebsitePanel.Providers.HostedSolution { private System.Threading.SendOrPostCallback GetSamAccountNameByUserPrincipalNameOperationCompleted; + private System.Threading.SendOrPostCallback DoesSamAccountNameExistOperationCompleted; + /// public Organizations() { this.Url = "http://localhost:9003/Organizations.asmx"; @@ -134,6 +135,9 @@ namespace WebsitePanel.Providers.HostedSolution { /// public event GetSamAccountNameByUserPrincipalNameCompletedEventHandler GetSamAccountNameByUserPrincipalNameCompleted; + /// + public event DoesSamAccountNameExistCompletedEventHandler DoesSamAccountNameExistCompleted; + /// [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/OrganizationExists", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] @@ -901,6 +905,48 @@ namespace WebsitePanel.Providers.HostedSolution { } } + /// + [System.Web.Services.Protocols.SoapHeaderAttribute("ServiceProviderSettingsSoapHeaderValue")] + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/DoesSamAccountNameExist", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public bool DoesSamAccountNameExist(string accountName) { + object[] results = this.Invoke("DoesSamAccountNameExist", new object[] { + accountName}); + return ((bool)(results[0])); + } + + /// + public System.IAsyncResult BeginDoesSamAccountNameExist(string accountName, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("DoesSamAccountNameExist", new object[] { + accountName}, callback, asyncState); + } + + /// + public bool EndDoesSamAccountNameExist(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((bool)(results[0])); + } + + /// + public void DoesSamAccountNameExistAsync(string accountName) { + this.DoesSamAccountNameExistAsync(accountName, null); + } + + /// + public void DoesSamAccountNameExistAsync(string accountName, object userState) { + if ((this.DoesSamAccountNameExistOperationCompleted == null)) { + this.DoesSamAccountNameExistOperationCompleted = new System.Threading.SendOrPostCallback(this.OnDoesSamAccountNameExistOperationCompleted); + } + this.InvokeAsync("DoesSamAccountNameExist", new object[] { + accountName}, this.DoesSamAccountNameExistOperationCompleted, userState); + } + + private void OnDoesSamAccountNameExistOperationCompleted(object arg) { + if ((this.DoesSamAccountNameExistCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.DoesSamAccountNameExistCompleted(this, new DoesSamAccountNameExistCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + /// public new void CancelAsync(object userState) { base.CancelAsync(userState); @@ -1090,4 +1136,30 @@ namespace WebsitePanel.Providers.HostedSolution { } } } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + public delegate void DoesSamAccountNameExistCompletedEventHandler(object sender, DoesSamAccountNameExistCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class DoesSamAccountNameExistCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal DoesSamAccountNameExistCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public bool Result { + get { + this.RaiseExceptionIfNecessary(); + return ((bool)(this.results[0])); + } + } + } } diff --git a/WebsitePanel/Sources/WebsitePanel.Server/Organizations.asmx.cs b/WebsitePanel/Sources/WebsitePanel.Server/Organizations.asmx.cs index 4b70e354..1e814394 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server/Organizations.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server/Organizations.asmx.cs @@ -162,5 +162,12 @@ namespace WebsitePanel.Server { return Organization.GetSamAccountNameByUserPrincipalName(organizationId, userPrincipalName); } + + [WebMethod, SoapHeader("settings")] + public bool DoesSamAccountNameExist(string accountName) + { + return Organization.DoesSamAccountNameExist(accountName); + } + } } diff --git a/WebsitePanel/Sources/generate_server_proxies.bat b/WebsitePanel/Sources/generate_server_proxies.bat index 2ef3d080..d4811b50 100644 --- a/WebsitePanel/Sources/generate_server_proxies.bat +++ b/WebsitePanel/Sources/generate_server_proxies.bat @@ -17,8 +17,8 @@ REM %WSE_CLEAN% .\WebsitePanel.Server.Client\DatabaseServerProxy.cs REM %WSDL% %SERVER_URL%/DNSServer.asmx /out:.\WebsitePanel.Server.Client\DnsServerProxy.cs /namespace:WebsitePanel.Providers.DNS /type:webClient /fields REM %WSE_CLEAN% .\WebsitePanel.Server.Client\DnsServerProxy.cs -%WSDL% %SERVER_URL%/ExchangeServer.asmx /out:.\WebsitePanel.Server.Client\ExchangeServerProxy.cs /namespace:WebsitePanel.Providers.Exchange /type:webClient /fields -%WSE_CLEAN% .\WebsitePanel.Server.Client\ExchangeServerProxy.cs +REM %WSDL% %SERVER_URL%/ExchangeServer.asmx /out:.\WebsitePanel.Server.Client\ExchangeServerProxy.cs /namespace:WebsitePanel.Providers.Exchange /type:webClient /fields +REM %WSE_CLEAN% .\WebsitePanel.Server.Client\ExchangeServerProxy.cs REM %WSDL% %SERVER_URL%/ExchangeServerHostedEdition.asmx /out:.\WebsitePanel.Server.Client\ExchangeServerHostedEditionProxy.cs /namespace:WebsitePanel.Providers.ExchangeHostedEdition /type:webClient /fields REM %WSE_CLEAN% .\WebsitePanel.Server.Client\ExchangeServerHostedEditionProxy.cs @@ -35,8 +35,8 @@ REM %WSE_CLEAN% .\WebsitePanel.Server.Client\OCSServerProxy.cs REM %WSDL% %SERVER_URL%/OperatingSystem.asmx /out:.\WebsitePanel.Server.Client\OperatingSystemProxy.cs /namespace:WebsitePanel.Providers.OS /type:webClient /fields REM %WSE_CLEAN% .\WebsitePanel.Server.Client\OperatingSystemProxy.cs -REM %WSDL% %SERVER_URL%/Organizations.asmx /out:.\WebsitePanel.Server.Client\OrganizationProxy.cs /namespace:WebsitePanel.Providers.HostedSolution /type:webClient /fields -REM %WSE_CLEAN% .\WebsitePanel.Server.Client\OrganizationProxy.cs +%WSDL% %SERVER_URL%/Organizations.asmx /out:.\WebsitePanel.Server.Client\OrganizationProxy.cs /namespace:WebsitePanel.Providers.HostedSolution /type:webClient /fields +%WSE_CLEAN% .\WebsitePanel.Server.Client\OrganizationProxy.cs REM %WSDL% %SERVER_URL%/ServiceProvider.asmx /out:.\WebsitePanel.Server.Client\ServiceProviderProxy.cs /namespace:WebsitePanel.Providers /type:webClient /fields REM %WSE_CLEAN% .\WebsitePanel.Server.Client\ServiceProviderProxy.cs