This commit is contained in:
Virtuworks 2014-10-28 11:10:30 -04:00
commit 70afba8215
8 changed files with 4242 additions and 3062 deletions

View file

@ -1782,7 +1782,9 @@ namespace WebsitePanel.EnterpriseServer
//GetServiceSettings
StringDictionary primSettings = ServerController.GetServiceSettings(exchangeServiceId);
string samAccount = exchange.CreateMailEnableUser(email, org.OrganizationId, org.DistinguishedName, accountType, primSettings["mailboxdatabase"],
string samAccount = exchange.CreateMailEnableUser(email, org.OrganizationId, org.DistinguishedName,
org.SecurityGroup, org.DefaultDomain,
accountType, primSettings["mailboxdatabase"],
org.OfflineAddressBook,
org.AddressBookPolicy,
retUser.SamAccountName,
@ -5317,6 +5319,54 @@ namespace WebsitePanel.EnterpriseServer
TaskManager.CompleteTask();
}
}
public static string CreateOrganizationRootPublicFolder(int itemId)
{
string res = null;
// place log record
TaskManager.StartTask("EXCHANGE", "CREATE_ORG_PUBLIC_FOLDER", itemId);
try
{
// load organization
Organization org = GetOrganization(itemId);
if (org == null)
return null;
// get mailbox settings
int exchangeServiceId = GetExchangeServiceID(org.PackageId);
if (exchangeServiceId <= 0)
return null;
ExchangeServer exchange = GetExchangeServer(exchangeServiceId, org.ServiceId);
if (exchange == null)
return null;
//Create Exchange Organization
if (string.IsNullOrEmpty(org.GlobalAddressList))
{
ExtendToExchangeOrganization(ref org);
PackageController.UpdatePackageItem(org);
}
res = exchange.CreateOrganizationRootPublicFolder(org.OrganizationId, org.DistinguishedName, org.SecurityGroup, org.DefaultDomain);
}
catch (Exception ex)
{
throw TaskManager.WriteError(ex);
}
finally
{
TaskManager.CompleteTask();
}
return res;
}
#endregion
#region Private Helpers

View file

@ -419,6 +419,9 @@ namespace WebsitePanel.EnterpriseServer
};
PackageController.AddPackageItem(orgDomain);
ExchangeServerController.CreateOrganizationRootPublicFolder(itemId);
}
catch (Exception ex)
{

View file

@ -37,7 +37,9 @@ namespace WebsitePanel.Providers.HostedSolution
bool CheckAccountCredentials(string username, string password);
// Organizations
string CreateMailEnableUser(string upn, string organizationId, string organizationDistinguishedName, ExchangeAccountType accountType,
string CreateMailEnableUser(string upn, string organizationId, string organizationDistinguishedName,
string securityGroup, string organizationDomain,
ExchangeAccountType accountType,
string mailboxDatabase, string offlineAddressBook, string addressBookPolicy,
string accountName, bool enablePOP, bool enableIMAP,
bool enableOWA, bool enableMAPI, bool enableActiveSync,
@ -74,6 +76,8 @@ namespace WebsitePanel.Providers.HostedSolution
void SetMailboxPermissions(string organizationId, string accountName, string[] sendAsAccounts, string[] fullAccessAccounts);
ExchangeMailbox GetMailboxPermissions(string organizationId, string accountName);
ExchangeMailboxStatistics GetMailboxStatistics(string accountName);
string[] SetDefaultPublicFolderMailbox(string id, string organizationId, string organizationDistinguishedName);
// Contacts
void CreateContact(string organizationId, string organizationDistinguishedName, string contactDisplayName, string contactAccountName, string contactEmail, string defaultOrganizationDomain);
@ -113,6 +117,8 @@ namespace WebsitePanel.Providers.HostedSolution
ExchangeItemStatistics[] GetPublicFoldersStatistics(string organizationId, string[] folders);
string[] GetPublicFoldersRecursive(string organizationId, string parent);
long GetPublicFolderSize(string organizationId, string folder);
string CreateOrganizationRootPublicFolder(string organizationId, string organizationDistinguishedName, string securityGroup, string organizationDomain);
//ActiveSync
void CreateOrganizationActiveSyncPolicy(string organizationId);

View file

@ -1871,14 +1871,18 @@ namespace WebsitePanel.Providers.HostedSolution
}
public string CreateMailEnableUser(string upn, string organizationId, string organizationDistinguishedName, ExchangeAccountType accountType,
public string CreateMailEnableUser(string upn, string organizationId, string organizationDistinguishedName,
string securityGroup, string organizationDomain,
ExchangeAccountType accountType,
string mailboxDatabase, string offlineAddressBook, string addressBookPolicy,
string accountName, bool enablePOP, bool enableIMAP,
bool enableOWA, bool enableMAPI, bool enableActiveSync,
long issueWarningKB, long prohibitSendKB, long prohibitSendReceiveKB, int keepDeletedItemsDays,
int maxRecipients, int maxSendMessageSizeKB, int maxReceiveMessageSizeKB, bool hideFromAddressBook, bool IsConsumer, bool enabledLitigationHold, long recoverabelItemsSpace, long recoverabelItemsWarning)
{
return CreateMailEnableUserInternal(upn, organizationId, organizationDistinguishedName, accountType,
return CreateMailEnableUserInternal(upn, organizationId, organizationDistinguishedName,
securityGroup, organizationDomain,
accountType,
mailboxDatabase, offlineAddressBook, addressBookPolicy,
accountName, enablePOP, enableIMAP,
enableOWA, enableMAPI, enableActiveSync,
@ -1886,7 +1890,9 @@ namespace WebsitePanel.Providers.HostedSolution
keepDeletedItemsDays, maxRecipients, maxSendMessageSizeKB, maxReceiveMessageSizeKB, hideFromAddressBook, IsConsumer, enabledLitigationHold, recoverabelItemsSpace, recoverabelItemsWarning);
}
internal virtual string CreateMailEnableUserInternal(string upn, string organizationId, string organizationDistinguishedName, ExchangeAccountType accountType,
internal virtual string CreateMailEnableUserInternal(string upn, string organizationId, string organizationDistinguishedName,
string securityGroup, string organizationDomain,
ExchangeAccountType accountType,
string mailboxDatabase, string offlineAddressBook, string addressBookPolicy,
string accountName, bool enablePOP, bool enableIMAP,
bool enableOWA, bool enableMAPI, bool enableActiveSync,
@ -1955,8 +1961,19 @@ namespace WebsitePanel.Providers.HostedSolution
transaction.RegisterEnableMailbox(id);
// default public folder
string orgCanonicalName = ConvertADPathToCanonicalName(organizationDistinguishedName);
//create organization public folder mailbox if required
CheckOrganizationPublicFolderMailbox(runSpace, orgCanonicalName, organizationId, organizationDomain);
//create organization root folder if required
CheckOrganizationRootFolder(runSpace, organizationId, securityGroup, orgCanonicalName, organizationId);
string windowsEmailAddress = ObjToString(GetPSObjectProperty(result[0], "WindowsEmailAddress"));
string defaultPublicFolderMailbox = orgCanonicalName + "/" + GetPublicFolderMailboxName(organizationId);
//update mailbox
cmd = new Command("Set-Mailbox");
cmd.Parameters.Add("Identity", id);
@ -1987,6 +2004,8 @@ namespace WebsitePanel.Providers.HostedSolution
cmd.Parameters.Add("RecoverableItemsWarningQuota", ConvertKBToUnlimited(recoverabelItemsWarning));
}
cmd.Parameters.Add("DefaultPublicFolderMailbox", defaultPublicFolderMailbox);
ExecuteShellCommand(runSpace, cmd);
//Litigation Hold
@ -4441,8 +4460,6 @@ namespace WebsitePanel.Providers.HostedSolution
ExchangeLog.LogEnd("CheckOrganizationPublicFolderMailbox");
}
private void CheckOrganizationRootFolder(Runspace runSpace, string folder, string user, string orgCanonicalName, string organizationId)
{
ExchangeLog.LogStart("CheckOrganizationRootFolder");
@ -4467,6 +4484,43 @@ namespace WebsitePanel.Providers.HostedSolution
ExchangeLog.LogEnd("CheckOrganizationRootFolder");
}
public string CreateOrganizationRootPublicFolder(string organizationId, string organizationDistinguishedName, string securityGroup, string organizationDomain)
{
ExchangeLog.LogStart("CreateOrganizationRootPublicFolder");
string res = null;
Runspace runSpace = null;
try
{
runSpace = OpenRunspace();
// default public folder
string orgCanonicalName = ConvertADPathToCanonicalName(organizationDistinguishedName);
//create organization public folder mailbox if required
CheckOrganizationPublicFolderMailbox(runSpace, orgCanonicalName, organizationId, organizationDomain);
//create organization root folder if required
CheckOrganizationRootFolder(runSpace, organizationId, securityGroup, orgCanonicalName, organizationId);
res = orgCanonicalName + "/" + GetPublicFolderMailboxName(organizationId);
string rootFolder = "\\" + organizationId;
// exchange transport needs access to create new items in order to deliver email
AddPublicFolderClientPermission(runSpace, rootFolder, "Anonymous", "CreateItems");
}
finally
{
CloseRunspace(runSpace);
}
ExchangeLog.LogEnd("CreateOrganizationRootPublicFolder");
return res;
}
private string AddPublicFolder(Runspace runSpace, string name, string path, string mailbox)
{
ExchangeLog.LogStart("CreatePublicFolder");
@ -4697,9 +4751,6 @@ namespace WebsitePanel.Providers.HostedSolution
System.Threading.Thread.Sleep(5000);
}
// exchange transport needs access to create new items in order to deliver email
AddPublicFolderClientPermission(runSpace, folder, "Anonymous", "CreateItems");
}
finally
{
@ -5209,6 +5260,54 @@ namespace WebsitePanel.Providers.HostedSolution
return size;
}
public string[] SetDefaultPublicFolderMailbox(string id, string organizationId, string organizationDistinguishedName)
{
ExchangeLog.LogStart("SetDefaultPublicFolderMailbox");
List<string> res = new List<string>();
Runspace runSpace = null;
try
{
runSpace = OpenRunspace();
Command cmd = new Command("Get-Mailbox");
cmd.Parameters.Add("Identity", id);
Collection<PSObject> result = ExecuteShellCommand(runSpace, cmd);
string oldValue = "";
if (result != null && result.Count > 0)
{
oldValue = ObjToString(GetPSObjectProperty(result[0], "DefaultPublicFolderMailbox"));
}
res.Add(oldValue);
string orgCanonicalName = ConvertADPathToCanonicalName(organizationDistinguishedName);
string newValue = orgCanonicalName + "/" + GetPublicFolderMailboxName(organizationId);
if (newValue != oldValue)
{
cmd = new Command("Set-Mailbox");
cmd.Parameters.Add("Identity", id);
cmd.Parameters.Add("DefaultPublicFolderMailbox", newValue);
res.Add(newValue);
}
}
finally
{
CloseRunspace(runSpace);
}
ExchangeLog.LogEnd("SetDefaultPublicFolderMailbox");
return res.ToArray();
}
#endregion
#region Address Lists (GAL, AL, RAL, OAB, ABP)

View file

@ -1784,7 +1784,9 @@ namespace WebsitePanel.Providers.HostedSolution
}
public string CreateMailEnableUser(string upn, string organizationId, string organizationDistinguishedName, ExchangeAccountType accountType,
public string CreateMailEnableUser(string upn, string organizationId, string organizationDistinguishedName,
string securityGroup, string organizationDomain,
ExchangeAccountType accountType,
string mailboxDatabase, string offlineAddressBook, string addressBookPolicy,
string accountName, bool enablePOP, bool enableIMAP,
bool enableOWA, bool enableMAPI, bool enableActiveSync,
@ -4852,6 +4854,19 @@ namespace WebsitePanel.Providers.HostedSolution
return size;
}
public string CreateOrganizationRootPublicFolder(string organizationId, string organizationDistinguishedName, string securityGroup, string organizationDomain)
{
// not implemented
return null;
}
public string[] SetDefaultPublicFolderMailbox(string id, string organizationId, string organizationDistinguishedName)
{
// not implemented
return null;
}
#endregion
#region Address Lists (GAL, AL, RAL, OAB, ABP)

View file

@ -325,7 +325,8 @@ namespace WebsitePanel.Providers.HostedSolution
#endregion
#region Mailbox
internal override string CreateMailEnableUserInternal(string upn, string organizationId, string organizationDistinguishedName, ExchangeAccountType accountType,
internal override string CreateMailEnableUserInternal(string upn, string organizationId, string organizationDistinguishedName,
ExchangeAccountType accountType,
string mailboxDatabase, string offlineAddressBook, string addressBookPolicy,
string accountName, bool enablePOP, bool enableIMAP,
bool enableOWA, bool enableMAPI, bool enableActiveSync,

View file

@ -90,7 +90,9 @@ namespace WebsitePanel.Server
}
[WebMethod, SoapHeader("settings")]
public string CreateMailEnableUser(string upn, string organizationId, string organizationDistinguishedName, ExchangeAccountType accountType,
public string CreateMailEnableUser(string upn, string organizationId, string organizationDistinguishedName,
string securityGroup, string organizationDomain,
ExchangeAccountType accountType,
string mailboxDatabase, string offlineAddressBook, string addressBookPolicy,
string accountName, bool enablePOP, bool enableIMAP,
bool enableOWA, bool enableMAPI, bool enableActiveSync,
@ -100,7 +102,9 @@ namespace WebsitePanel.Server
try
{
LogStart("CreateMailEnableUser");
string ret = ES.CreateMailEnableUser(upn, organizationId, organizationDistinguishedName, accountType,
string ret = ES.CreateMailEnableUser(upn, organizationId, organizationDistinguishedName,
securityGroup, organizationDomain,
accountType,
mailboxDatabase, offlineAddressBook, addressBookPolicy,
accountName, enablePOP, enableIMAP,
enableOWA, enableMAPI, enableActiveSync,
@ -556,6 +560,24 @@ namespace WebsitePanel.Server
}
}
[WebMethod, SoapHeader("settings")]
public string[] SetDefaultPublicFolderMailbox(string id, string organizationId, string organizationDistinguishedName)
{
try
{
LogStart("SetDefaultPublicFolderMailbox");
string[] ret = ES.SetDefaultPublicFolderMailbox(id, organizationId, organizationDistinguishedName);
LogEnd("SetDefaultPublicFolderMailbox");
return ret;
}
catch (Exception ex)
{
Log.WriteError("SetDefaultPublicFolderMailbox", ex);
throw;
}
}
#endregion
#region Contacts
@ -1084,6 +1106,23 @@ namespace WebsitePanel.Server
throw;
}
}
[WebMethod, SoapHeader("settings")]
public string CreateOrganizationRootPublicFolder(string organizationId, string organizationDistinguishedName, string securityGroup, string organizationDomain)
{
try
{
LogStart("CreateOrganizationRootPublicFolder");
string ret = ES.CreateOrganizationRootPublicFolder(organizationId, organizationDistinguishedName, securityGroup, organizationDomain);
LogEnd("CreateOrganizationRootPublicFolder");
return ret;
}
catch (Exception ex)
{
Log.WriteError("CreateOrganizationRootPublicFolder", ex);
throw;
}
}
#endregion