wsp-10200 Domain remains in "Accepted domains" in Exchange 2010/13 environment

after deletion hosted organization/space from WSP

Fixed
This commit is contained in:
robvde 2014-07-13 09:44:53 +08:00
parent 24ad3c2c25
commit 4bcfe5f5cf
15 changed files with 2777 additions and 3432 deletions

View file

@ -496,7 +496,7 @@ namespace WebsitePanel.EnterpriseServer
// rollback organization creation
if (organizationExtended)
mailboxRole.DeleteOrganization(org.OrganizationId, org.DistinguishedName,
org.GlobalAddressList, org.AddressList, org.RoomsAddressList, org.OfflineAddressBook, org.SecurityGroup, org.AddressBookPolicy);
org.GlobalAddressList, org.AddressList, org.RoomsAddressList, org.OfflineAddressBook, org.SecurityGroup, org.AddressBookPolicy, null);
// rollback domain
if (authDomainCreated)
@ -583,6 +583,8 @@ namespace WebsitePanel.EnterpriseServer
//System.Threading.Thread.Sleep(5000);
Organization org = (Organization)PackageController.GetPackageItem(itemId);
List<ExchangeDomainName> acceptedDomains = GetOrganizationDomains(itemId);
int exchangeServiceId = GetExchangeServiceID(org.PackageId);
ExchangeServer exchange = GetExchangeServer(exchangeServiceId, org.ServiceId);
@ -594,7 +596,8 @@ namespace WebsitePanel.EnterpriseServer
org.RoomsAddressList,
org.OfflineAddressBook,
org.SecurityGroup,
org.AddressBookPolicy);
org.AddressBookPolicy,
acceptedDomains.ToArray());
return successful ? 0 : BusinessErrorCodes.ERROR_EXCHANGE_DELETE_SOME_PROBLEMS;

View file

@ -26,6 +26,7 @@
// (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.Collections.Generic;
using WebsitePanel.Providers.Common;
namespace WebsitePanel.Providers.HostedSolution
@ -48,7 +49,7 @@ namespace WebsitePanel.Providers.HostedSolution
Organization CreateOrganizationOfflineAddressBook(string organizationId, string securityGroup, string oabVirtualDir);
Organization CreateOrganizationAddressBookPolicy(string organizationId, string gal, string addressBook, string roomList, string oab);
void UpdateOrganizationOfflineAddressBook(string id);
bool DeleteOrganization(string organizationId, string distinguishedName, string globalAddressList, string addressList, string roomList, string offlineAddressBook, string securityGroup, string addressBookPolicy);
bool DeleteOrganization(string organizationId, string distinguishedName, string globalAddressList, string addressList, string roomList, string offlineAddressBook, string securityGroup, string addressBookPolicy, List<ExchangeDomainName> acceptedDomains);
void SetOrganizationStorageLimits(string organizationDistinguishedName, long issueWarningKB, long prohibitSendKB, long prohibitSendReceiveKB, int keepDeletedItemsDays);
ExchangeItemStatistics[] GetMailboxesStatistics(string organizationDistinguishedName);

View file

@ -211,10 +211,10 @@ namespace WebsitePanel.Providers.HostedSolution
public bool DeleteOrganization(string organizationId, string distinguishedName,
string globalAddressList, string addressList, string roomList, string offlineAddressBook,
string securityGroup, string addressBookPolicy)
string securityGroup, string addressBookPolicy, List<ExchangeDomainName> acceptedDomains)
{
return DeleteOrganizationInternal(organizationId, distinguishedName, globalAddressList,
addressList, roomList, offlineAddressBook, securityGroup, addressBookPolicy);
addressList, roomList, offlineAddressBook, securityGroup, addressBookPolicy, acceptedDomains);
}
public void SetOrganizationStorageLimits(string organizationDistinguishedName, long issueWarningKB, long prohibitSendKB,
@ -675,11 +675,11 @@ namespace WebsitePanel.Providers.HostedSolution
{
Organization org = item as Organization;
DeleteOrganization(org.OrganizationId, org.DistinguishedName, org.GlobalAddressList,
org.AddressList, org.RoomsAddressList, org.OfflineAddressBook, org.SecurityGroup, org.AddressBookPolicy);
org.AddressList, org.RoomsAddressList, org.OfflineAddressBook, org.SecurityGroup, org.AddressBookPolicy, null);
}
else if (item is ExchangeDomain)
{
DeleteAcceptedDomain(item.Name);
DeleteAcceptedDomain(null, item.Name);
}
}
catch (Exception ex)
@ -989,7 +989,7 @@ namespace WebsitePanel.Providers.HostedSolution
internal virtual bool DeleteOrganizationInternal(string organizationId, string distinguishedName,
string globalAddressList, string addressList, string roomList, string offlineAddressBook, string securityGroup, string addressBookPolicy)
string globalAddressList, string addressList, string roomList, string offlineAddressBook, string securityGroup, string addressBookPolicy, List<ExchangeDomainName> acceptedDomains)
{
ExchangeLog.LogStart("DeleteOrganizationInternal");
bool ret = true;
@ -1002,6 +1002,8 @@ namespace WebsitePanel.Providers.HostedSolution
string ou = ConvertADPathToCanonicalName(distinguishedName);
if (!DeleteOrganizationMailboxes(runSpace, ou))
ret = false;
@ -1093,6 +1095,9 @@ namespace WebsitePanel.Providers.HostedSolution
ret = false;
ExchangeLog.LogError("Could not disable mail security distribution group " + securityGroup, ex);
}
if (!DeleteOrganizationAcceptedDomains(runSpace, acceptedDomains))
ret = false;
}
catch (Exception ex)
{
@ -1268,6 +1273,33 @@ namespace WebsitePanel.Providers.HostedSolution
return ret;
}
private bool DeleteOrganizationAcceptedDomains(Runspace runSpace, List<ExchangeDomainName> acceptedDomains)
{
ExchangeLog.LogStart("DeleteOrganizationAcceptedDomains");
bool ret = true;
if (acceptedDomains != null)
{
foreach (ExchangeDomainName domain in acceptedDomains)
{
try
{
DeleteAcceptedDomain(runSpace, domain.DomainName);
}
catch (Exception ex)
{
ExchangeLog.LogError(string.Format("Failed to delete accepted domain {0}", domain), ex);
ret = false;
}
}
}
ExchangeLog.LogEnd("DeleteOrganizationAcceptedDomains");
return ret;
}
private void SetOrganizationStorageLimitsInternal(string organizationDistinguishedName, long issueWarningKB,
long prohibitSendKB, long prohibitSendReceiveKB, int keepDeletedItemsDays)
{
@ -6428,14 +6460,19 @@ namespace WebsitePanel.Providers.HostedSolution
ExchangeLog.LogEnd("ChangeAcceptedDomainType");
}
private void DeleteAcceptedDomain(string domainName)
private void DeleteAcceptedDomain(Runspace runSpace, string domainName)
{
ExchangeLog.LogStart("DeleteAcceptedDomain");
Runspace runSpace = null;
bool bCloseRunSpace = false;
try
{
if (runSpace == null)
{
bCloseRunSpace = true;
runSpace = OpenRunspace();
}
RemoveAcceptedDomain(runSpace, domainName);
}
@ -6447,7 +6484,7 @@ namespace WebsitePanel.Providers.HostedSolution
finally
{
CloseRunspace(runSpace);
if (bCloseRunSpace) CloseRunspace(runSpace);
}
ExchangeLog.LogEnd("DeleteAcceptedDomain");
@ -6461,7 +6498,7 @@ namespace WebsitePanel.Providers.HostedSolution
{
ExchangeLog.LogStart("DeleteDomainInternal");
//Delete accepted domain
DeleteAcceptedDomain(domain);
DeleteAcceptedDomain(null, domain);
ExchangeLog.LogEnd("DeleteDomainInternal");
}

View file

@ -17,7 +17,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\WebsitePanel.Server\bin\Lync2013HP\</OutputPath>
<OutputPath>..\WebsitePanel.Server\bin\Lync2013\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>

View file

@ -196,10 +196,10 @@ namespace WebsitePanel.Providers.HostedSolution
public bool DeleteOrganization(string organizationId, string distinguishedName,
string globalAddressList, string addressList, string roomList, string offlineAddressBook,
string securityGroup, string addressBookPolicy)
string securityGroup, string addressBookPolicy, List<ExchangeDomainName> acceptedDomains)
{
return DeleteOrganizationInternal(organizationId, distinguishedName, globalAddressList,
addressList, roomList, offlineAddressBook, securityGroup, addressBookPolicy);
addressList, roomList, offlineAddressBook, securityGroup, addressBookPolicy, acceptedDomains);
}
public void SetOrganizationStorageLimits(string organizationDistinguishedName, long issueWarningKB, long prohibitSendKB,
@ -616,11 +616,11 @@ namespace WebsitePanel.Providers.HostedSolution
{
Organization org = item as Organization;
DeleteOrganization(org.OrganizationId, org.DistinguishedName, org.GlobalAddressList,
org.AddressList, org.RoomsAddressList, org.OfflineAddressBook, org.SecurityGroup, org.AddressBookPolicy);
org.AddressList, org.RoomsAddressList, org.OfflineAddressBook, org.SecurityGroup, org.AddressBookPolicy, null);
}
else if (item is ExchangeDomain)
{
DeleteAcceptedDomain(item.Name);
DeleteAcceptedDomain(null, item.Name);
}
}
catch (Exception ex)
@ -902,7 +902,7 @@ namespace WebsitePanel.Providers.HostedSolution
internal virtual bool DeleteOrganizationInternal(string organizationId, string distinguishedName,
string globalAddressList, string addressList, string roomsAddressList, string offlineAddressBook, string securityGroup, string addressBookPolicy)
string globalAddressList, string addressList, string roomsAddressList, string offlineAddressBook, string securityGroup, string addressBookPolicy, List<ExchangeDomainName> acceptedDomains)
{
ExchangeLog.LogStart("DeleteOrganizationInternal");
bool ret = true;
@ -1005,6 +1005,9 @@ namespace WebsitePanel.Providers.HostedSolution
ret = false;
ExchangeLog.LogError("Could not disable mail security distribution group " + securityGroup, ex);
}
if (!DeleteOrganizationAcceptedDomains(runSpace, acceptedDomains))
ret = false;
}
catch (Exception ex)
{
@ -1181,6 +1184,33 @@ namespace WebsitePanel.Providers.HostedSolution
return ret;
}
internal bool DeleteOrganizationAcceptedDomains(Runspace runSpace, List<ExchangeDomainName> acceptedDomains)
{
ExchangeLog.LogStart("DeleteOrganizationAcceptedDomains");
bool ret = true;
if (acceptedDomains != null)
{
foreach (ExchangeDomainName domain in acceptedDomains)
{
try
{
DeleteAcceptedDomain(runSpace, domain.DomainName);
}
catch (Exception ex)
{
ExchangeLog.LogError(string.Format("Failed to delete accepted domain {0}", domain), ex);
ret = false;
}
}
}
ExchangeLog.LogEnd("DeleteOrganizationAcceptedDomains");
return ret;
}
private void SetOrganizationStorageLimitsInternal(string organizationDistinguishedName, long issueWarningKB,
long prohibitSendKB, long prohibitSendReceiveKB, int keepDeletedItemsDays)
{
@ -6000,14 +6030,19 @@ namespace WebsitePanel.Providers.HostedSolution
ExchangeLog.LogEnd("ChangeAcceptedDomainType");
}
private void DeleteAcceptedDomain(string domainName)
private void DeleteAcceptedDomain(Runspace runSpace, string domainName)
{
ExchangeLog.LogStart("DeleteAcceptedDomain");
Runspace runSpace = null;
bool bCloseRunSpace = false;
try
{
if (runSpace == null)
{
bCloseRunSpace = true;
runSpace = OpenRunspace();
}
RemoveAcceptedDomain(runSpace, domainName);
}
@ -6019,7 +6054,7 @@ namespace WebsitePanel.Providers.HostedSolution
finally
{
CloseRunspace(runSpace);
if (bCloseRunSpace) CloseRunspace(runSpace);
}
ExchangeLog.LogEnd("DeleteAcceptedDomain");
@ -6033,7 +6068,7 @@ namespace WebsitePanel.Providers.HostedSolution
{
ExchangeLog.LogStart("DeleteDomainInternal");
//Delete accepted domain
DeleteAcceptedDomain(domain);
DeleteAcceptedDomain(null, domain);
ExchangeLog.LogEnd("DeleteDomainInternal");
}

View file

@ -186,7 +186,7 @@ namespace WebsitePanel.Providers.HostedSolution
}
internal override bool DeleteOrganizationInternal(string organizationId, string distinguishedName,
string globalAddressList, string addressList, string roomList, string offlineAddressBook, string securityGroup, string addressBookPolicy)
string globalAddressList, string addressList, string roomList, string offlineAddressBook, string securityGroup, string addressBookPolicy, List<ExchangeDomainName> acceptedDomains)
{
ExchangeLog.LogStart("DeleteOrganizationInternal");
bool ret = true;
@ -290,6 +290,9 @@ namespace WebsitePanel.Providers.HostedSolution
ret = false;
ExchangeLog.LogError("Could not disable mail security distribution group " + securityGroup, ex);
}
if (!DeleteOrganizationAcceptedDomains(runSpace, acceptedDomains))
ret = false;
}
catch (Exception ex)
{

View file

@ -1322,7 +1322,7 @@ namespace WebsitePanel.Providers.HostedSolution
ExecuteShellCommand(runSpace, cmd);
}
catch (Exception ex)
catch (Exception)
{
CloseRunspace(runSpace);
@ -1406,7 +1406,7 @@ namespace WebsitePanel.Providers.HostedSolution
xml.Save(drivesXmlPath);
}
}
catch (Exception ex)
catch (Exception)
{
throw;
}
@ -1466,7 +1466,7 @@ namespace WebsitePanel.Providers.HostedSolution
xml.Save(drivesXmlPath);
}
}
catch (Exception ex)
catch (Exception)
{
CloseRunspace(runSpace);
@ -1517,7 +1517,7 @@ namespace WebsitePanel.Providers.HostedSolution
//create empty drives.xml file for for gpo drives mapping
CreateDrivesXmlEmpty(string.Format(GROUP_POLICY_MAPPED_DRIVES_FILE_PATH_TEMPLATE, RootDomain, gpoId), "Drives.xml");
}
catch (Exception ex)
catch (Exception)
{
gpoId = null;
CloseRunspace(runSpace);
@ -1553,7 +1553,7 @@ namespace WebsitePanel.Providers.HostedSolution
gpoId = ((Guid)GetPSObjectProperty(gpo, "Id")).ToString("B");
}
}
catch (Exception ex)
catch (Exception)
{
gpoId = null;
CloseRunspace(runSpace);

View file

@ -47,8 +47,7 @@ using System.Management.Automation;
using System.Management.Automation.Runspaces;
using WebsitePanel.Providers.Common;
using WebsitePanel.Providers;
using WebsitePanel.Providers.HostedSolution;
using System.Runtime.InteropServices;

View file

@ -125,8 +125,8 @@ namespace WebsitePanel.Providers.RemoteDesktopServices
// TODO: Remove it.
return true;
Server.Utils.OS.WindowsVersion version = WebsitePanel.Server.Utils.OS.GetVersion();
return version == WebsitePanel.Server.Utils.OS.WindowsVersion.WindowsServer2012;
//Server.Utils.OS.WindowsVersion version = WebsitePanel.Server.Utils.OS.GetVersion();
//return version == WebsitePanel.Server.Utils.OS.WindowsVersion.WindowsServer2012;
}
}
}

View file

@ -196,7 +196,7 @@ namespace WebsitePanel.Providers.Web.WPIWebApplicationGallery
applications.Add(MakeGalleryApplicationFromProduct(product));
}
}
catch(Exception ex)
catch(Exception)
{
//
}

View file

@ -130,8 +130,9 @@ namespace WebsitePanel.Server
try
{
Log.WriteStart("'{0}' SetFolderWebDavRules", ProviderSettings.ProviderName);
return EnterpriseStorageProvider.SetFolderWebDavRules(organizationId, folder, setting, rules);
bool bResult = EnterpriseStorageProvider.SetFolderWebDavRules(organizationId, folder, setting, rules);
Log.WriteEnd("'{0}' SetFolderWebDavRules", ProviderSettings.ProviderName);
return bResult;
}
catch (Exception ex)
{
@ -146,8 +147,9 @@ namespace WebsitePanel.Server
try
{
Log.WriteStart("'{0}' GetFolderWebDavRules", ProviderSettings.ProviderName);
return EnterpriseStorageProvider.GetFolderWebDavRules(organizationId, folder, setting);
Providers.Web.WebDavFolderRule[] webDavFolderRule = EnterpriseStorageProvider.GetFolderWebDavRules(organizationId, folder, setting);
Log.WriteEnd("'{0}' GetFolderWebDavRules", ProviderSettings.ProviderName);
return webDavFolderRule;
}
catch (Exception ex)
{
@ -162,8 +164,9 @@ namespace WebsitePanel.Server
try
{
Log.WriteStart("'{0}' CheckFileServicesInstallation", ProviderSettings.ProviderName);
return EnterpriseStorageProvider.CheckFileServicesInstallation();
bool bResult = EnterpriseStorageProvider.CheckFileServicesInstallation();
Log.WriteEnd("'{0}' CheckFileServicesInstallation", ProviderSettings.ProviderName);
return bResult;
}
catch (Exception ex)
{
@ -178,8 +181,9 @@ namespace WebsitePanel.Server
try
{
Log.WriteStart("'{0}' RenameFolder", ProviderSettings.ProviderName);
return EnterpriseStorageProvider.RenameFolder(organizationId, originalFolder, newFolder, setting);
SystemFile systemFile = EnterpriseStorageProvider.RenameFolder(organizationId, originalFolder, newFolder, setting);
Log.WriteEnd("'{0}' RenameFolder", ProviderSettings.ProviderName);
return systemFile;
}
catch (Exception ex)
{

View file

@ -30,6 +30,7 @@ using System;
using System.ComponentModel;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Collections.Generic;
using WebsitePanel.Providers;
using WebsitePanel.Providers.HostedSolution;
using WebsitePanel.Server.Utils;
@ -197,12 +198,12 @@ namespace WebsitePanel.Server
[WebMethod, SoapHeader("settings")]
public bool DeleteOrganization(string organizationId, string distinguishedName, string globalAddressList, string addressList, string roomList, string offlineAddressBook, string securityGroup, string addressBookPolicy)
public bool DeleteOrganization(string organizationId, string distinguishedName, string globalAddressList, string addressList, string roomList, string offlineAddressBook, string securityGroup, string addressBookPolicy, List<ExchangeDomainName> acceptedDomains)
{
try
{
LogStart("DeleteOrganization");
bool ret = ES.DeleteOrganization(organizationId, distinguishedName, globalAddressList, addressList, roomList, offlineAddressBook, securityGroup, addressBookPolicy);
bool ret = ES.DeleteOrganization(organizationId, distinguishedName, globalAddressList, addressList, roomList, offlineAddressBook, securityGroup, addressBookPolicy, acceptedDomains);
LogEnd("DeleteOrganization");
return ret;
}

View file

@ -590,8 +590,9 @@ namespace WebsitePanel.Server
try
{
Log.WriteStart("'{0}' CheckFileServicesInstallation", ProviderSettings.ProviderName);
return OsProvider.CheckFileServicesInstallation();
bool bResult = OsProvider.CheckFileServicesInstallation();
Log.WriteEnd("'{0}' CheckFileServicesInstallation", ProviderSettings.ProviderName);
return bResult;
}
catch (Exception ex)
{

View file

@ -1198,9 +1198,11 @@ namespace WebsitePanel.Server
{
Log.WriteStart("CheckLoadUserProfile");
return WebProvider.CheckLoadUserProfile();
bool bResult = WebProvider.CheckLoadUserProfile();
Log.WriteEnd("CheckLoadUserProfile");
return bResult;
}
catch (Exception ex)
{