public static List <ExchangeOrganizationDomain> GetOrganizationDomains(int itemId) { // load organization item ExchangeOrganization item = PackageController.GetPackageItem(itemId) as ExchangeOrganization; if (item == null) { return(null); // organization item not found } // get Exchange service ExchangeServerHostedEdition exchange = GetExchangeService(item.ServiceId); // get organization domains List <ExchangeOrganizationDomain> domains = new List <ExchangeOrganizationDomain>(); domains.AddRange(exchange.GetOrganizationDomains(item.Name)); return(domains); //return new List<ExchangeOrganizationDomain> //{ // new ExchangeOrganizationDomain { Identity = "org101\\domain1.com", Name = "domain1.com", IsDefault = true, IsTemp = false }, // new ExchangeOrganizationDomain { Identity = "org101\\org101.tempdomain.com", Name = "org101.tempdomain.com", IsDefault = false, IsTemp = true }, // new ExchangeOrganizationDomain { Identity = "org101\\myseconddomain.com", Name = "myseconddomain.com", IsDefault = false, IsTemp = false } //}; }
private void BindOrganizationDetails() { ExchangeOrganization org = ES.Services.ExchangeHostedEdition.GetExchangeOrganizationDetails(PanelRequest.ItemID); if (org == null) { return; } // selected service ListItem sourceItem = null; foreach (ListItem item in services.Items) { if (item.Value == org.ServiceId.ToString()) { sourceItem = item; currentServiceName.Text = item.Text; break; } } if (sourceItem != null) { services.Items.Remove(sourceItem); } currentProgramID.Text = org.ProgramId; currentOfferID.Text = org.OfferId; }
public static ResultObject DeleteOrganization(int itemId) { ResultObject result = new ResultObject(); result.IsSuccess = true; try { // initialize task manager TaskManager.StartTask(TaskManagerSource, "DELETE_ORGANIZATION"); TaskManager.WriteParameter("itemId", itemId); // load organization item ExchangeOrganization item = PackageController.GetPackageItem(itemId) as ExchangeOrganization; if (item == null) { return(Error <ResultObject>(OrganizationNotFoundError)); } #region Check Space and Account // Check account int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); if (accountCheck < 0) { return(Warning <ResultObject>((-accountCheck).ToString())); } // Check space int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive); if (packageCheck < 0) { return(Warning <ResultObject>((-packageCheck).ToString())); } #endregion // get Exchange service ExchangeServerHostedEdition exchange = GetExchangeService(item.ServiceId); // delete organization exchange.DeleteOrganization(item.Name); // delete meta-item PackageController.DeletePackageItem(itemId); return(result); } catch (Exception ex) { // log error TaskManager.WriteError(ex); // exit with error code return(Error <ResultObject>(DeleteOrganizationError, ex.Message)); } finally { TaskManager.CompleteTask(); } }
public static string GetExchangeOrganizationSummary(int itemId) { // load organization details ExchangeOrganization org = GetOrganizationDetails(itemId); if (org == null) { return(null); // organization not found } return(GetExchangeOrganizationSummary(org)); }
private static string GetExchangeOrganizationSummary(ExchangeOrganization org) { // evaluate template MailTemplate template = EvaluateOrganizationSummaryTemplate(org); if (template == null || template.Body == null) { return(null); } return(template.IsHtml ? template.Body : template.Body.Replace("\n", "<br/>")); }
private void BindOrganization(int itemId) { // load organization details ExchangeOrganization org = null; try { org = ES.Services.ExchangeHostedEdition.GetExchangeOrganizationDetails(itemId); if (org == null) { throw new ArgumentNullException("Organization not found"); } } catch (Exception ex) { messageBox.ShowErrorMessage("EXCHANGE_HOSTED_GET_ORGANIZATION", ex); return; } // basic details ItemID = org.Id; organizationName.Text = org.Name; administratorName.Text = org.AdministratorName; administratorEmail.Text = org.AdministratorEmail; ecpURL.Text = org.ExchangeControlPanelUrl; ecpURL.NavigateUrl = org.ExchangeControlPanelUrl; // service plan serviceName.Text = org.ServicePlan; programID.Text = org.ProgramId; offerID.Text = org.OfferId; servicePlanBlock.Visible = (PanelSecurity.LoggedUser.Role == EnterpriseServer.UserRole.Administrator); // quotas string quotaFormat = GetLocalizedString("quota.FormatText"); mailboxes.Text = String.Format(quotaFormat, org.MailboxCount, FormatUnlimited(org.MailboxCountQuota), FormatUnlimited(org.MaxMailboxCountQuota)); contacts.Text = String.Format(quotaFormat, org.ContactCount, FormatUnlimited(org.ContactCountQuota), FormatUnlimited(org.MaxContactCountQuota)); distributionLists.Text = String.Format(quotaFormat, org.DistributionListCount, FormatUnlimited(org.DistributionListCountQuota), FormatUnlimited(org.MaxDistributionListCountQuota)); // catch-all //catchAllAddress.Text = !String.IsNullOrEmpty(org.CatchAllAddress) ? org.CatchAllAddress : GetLocalizedString("catchAllNotSet.Text"); // domains BindOrganizationDomains(org); // summary BindOrganizationSummary(org); }
private void BindOrganizationQuotas() { // load organization details ExchangeOrganization org = null; try { org = ES.Services.ExchangeHostedEdition.GetExchangeOrganizationDetails(PanelRequest.ItemID); if (org == null) { throw new ArgumentNullException("Organization not found"); } } catch (Exception ex) { messageBox.ShowErrorMessage("EXCHANGE_HOSTED_GET_ORGANIZATION", ex); return; } // current quotas mailboxes.Text = IsUnlimited(org.MailboxCountQuota) ? "" : org.MailboxCountQuota.ToString(); contacts.Text = IsUnlimited(org.ContactCountQuota) ? "" : org.ContactCountQuota.ToString(); distributionLists.Text = IsUnlimited(org.DistributionListCountQuota) ? "" : org.DistributionListCountQuota.ToString(); // max quotas string maxQuotaFormat = GetLocalizedString("maxQuota.Text"); maxMailboxes.Text = String.Format(maxQuotaFormat, FormatUnlimited(org.MaxMailboxCountQuota)); maxContacts.Text = String.Format(maxQuotaFormat, FormatUnlimited(org.MaxContactCountQuota)); maxDistributionLists.Text = String.Format(maxQuotaFormat, FormatUnlimited(org.MaxDistributionListCountQuota)); if (!IsUnlimited(org.MaxMailboxCountQuota)) { requireMailboxes.Enabled = true; rangeMailboxes.MaximumValue = org.MaxMailboxCountQuota.ToString(); } if (!IsUnlimited(org.MaxContactCountQuota)) { requireContacts.Enabled = true; rangeContacts.MaximumValue = org.MaxContactCountQuota.ToString(); } if (!IsUnlimited(org.MaxDistributionListCountQuota)) { requireDistributionLists.Enabled = true; rangeDistributionLists.MaximumValue = org.MaxDistributionListCountQuota.ToString(); } }
public static void UpdateOrganizationQuotas(ExchangeOrganization org) { // load default package quotas PackageContext cntx = PackageController.GetPackageContext(org.PackageId); if (!cntx.Groups.ContainsKey(ResourceGroups.ExchangeHostedEdition)) { return; } org.MaxMailboxCountQuota = cntx.Quotas[Quotas.EXCHANGEHOSTEDEDITION_MAILBOXES].QuotaAllocatedValue; org.MaxContactCountQuota = cntx.Quotas[Quotas.EXCHANGEHOSTEDEDITION_CONTACTS].QuotaAllocatedValue; org.MaxDistributionListCountQuota = cntx.Quotas[Quotas.EXCHANGEHOSTEDEDITION_DISTRIBUTIONLISTS].QuotaAllocatedValue; org.MaxDomainsCountQuota = cntx.Quotas[Quotas.EXCHANGEHOSTEDEDITION_DOMAINS].QuotaAllocatedValue; }
public ExchangeOrganization GetOrganizationDetails(string organizationId) { try { Log.WriteStart("'{0}' GetOrganizationDetails", ProviderSettings.ProviderName); ExchangeOrganization result = ExchangeServer.GetOrganizationDetails(organizationId); Log.WriteEnd("'{0}' GetOrganizationDetails", ProviderSettings.ProviderName); return(result); } catch (Exception ex) { Log.WriteError(String.Format("'{0}' GetOrganizationDetails", ProviderSettings.ProviderName), ex); throw; } }
private void BindOrganizationSummary(ExchangeOrganization org) { try { string summaryText = ES.Services.ExchangeHostedEdition.GetExchangeOrganizationSummary(org.Id); setupInstructions.Text = !String.IsNullOrEmpty(summaryText) ? summaryText : GetLocalizedString("summaryTemplateNotSet.Text"); // hide block if template is not set organizationSummary.Visible = !String.IsNullOrEmpty(summaryText) || (PanelSecurity.LoggedUser.Role != EnterpriseServer.UserRole.User); } catch (Exception ex) { messageBox.ShowErrorMessage("EXCHANGE_HOSTED_GET_DOMAINS", ex); return; } }
private void BindOrganizationDomains(ExchangeOrganization org) { try { // bind grid gvDomains.DataSource = org.Domains; gvDomains.DataBind(); // set gauge domainsQuota.QuotaValue = org.MaxDomainsCountQuota; domainsQuota.QuotaUsedValue = org.Domains.Length; } catch (Exception ex) { messageBox.ShowErrorMessage("EXCHANGE_HOSTED_GET_DOMAINS", ex); return; } }
public static List <LyncUserPlan> GetLyncUserPlans(int itemId) { // place log record TaskManager.StartTask("LYNC", "GET_LYNC_LYNCUSERPLANS", itemId); try { List <LyncUserPlan> plans = new List <LyncUserPlan>(); UserInfo user = ObjectUtils.FillObjectFromDataReader <UserInfo>(DataProvider.GetUserByExchangeOrganizationIdInternally(itemId)); if (user.Role == UserRole.User) { LyncController.GetLyncUserPlansByUser(itemId, user, ref plans); } else { LyncController.GetLyncUserPlansByUser(0, user, ref plans); } ExchangeOrganization ExchangeOrg = ObjectUtils.FillObjectFromDataReader <ExchangeOrganization>(DataProvider.GetExchangeOrganization(itemId)); if (ExchangeOrg != null) { foreach (LyncUserPlan p in plans) { p.IsDefault = (p.LyncUserPlanId == ExchangeOrg.LyncUserPlanID); } } return(plans); } catch (Exception ex) { throw TaskManager.WriteError(ex); } finally { TaskManager.CompleteTask(); } }
private static MailTemplate EvaluateOrganizationSummaryTemplate(ExchangeOrganization org) { #region create template context Hashtable items = new Hashtable(); // add organization items["org"] = org; // add package information PackageInfo space = PackageController.GetPackage(org.PackageId); items["space"] = space; // add user information UserInfo user = UserController.GetUser(space.UserId); items["user"] = user; #endregion #region load template // load template settings UserSettings settings = UserController.GetUserSettings(user.UserId, UserSettings.EXCHANGE_HOSTED_EDITION_ORGANIZATION_SUMMARY); if (settings == null) { return(null); } // create template MailTemplate template = new MailTemplate(); // from template.From = settings["From"]; // BCC template.Bcc = settings["CC"]; // subject template.Subject = settings["Subject"]; // body template.IsHtml = user.HtmlMail; string bodySetting = template.IsHtml ? "HtmlBody" : "TextBody"; template.Body = settings[bodySetting]; // priority string priority = settings["Priority"]; template.Priority = String.IsNullOrEmpty(priority) ? MailPriority.Normal : (MailPriority)Enum.Parse(typeof(MailPriority), priority, true); #endregion #region evaluate template if (template.Subject != null) { template.Subject = PackageController.EvaluateTemplate(template.Subject, items); } if (template.Body != null) { template.Body = PackageController.EvaluateTemplate(template.Body, items); } #endregion return(template); }
public static ResultObject UpdateOrganizationQuotas(int itemId, int mailboxesNumber, int contactsNumber, int distributionListsNumber) { ResultObject result = new ResultObject(); result.IsSuccess = true; try { // initialize task manager TaskManager.StartTask(TaskManagerSource, "UPDATE_QUOTAS"); TaskManager.WriteParameter("itemId", itemId); TaskManager.WriteParameter("mailboxesNumber", mailboxesNumber); TaskManager.WriteParameter("contactsNumber", contactsNumber); TaskManager.WriteParameter("distributionListsNumber", distributionListsNumber); // load organization item ExchangeOrganization item = PackageController.GetPackageItem(itemId) as ExchangeOrganization; if (item == null) { return(Error <ResultObject>(OrganizationNotFoundError)); } #region Check Space and Account // Check account int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); if (accountCheck < 0) { return(Warning <ResultObject>((-accountCheck).ToString())); } // Check space int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive); if (packageCheck < 0) { return(Warning <ResultObject>((-packageCheck).ToString())); } #endregion // check quotas UpdateOrganizationQuotas(item); if (item.MaxMailboxCountQuota > -1 && mailboxesNumber > item.MaxMailboxCountQuota) { return(Error <ResultObject>(UpdateQuotasWrongQuotaError)); } if (item.MaxContactCountQuota > -1 && contactsNumber > item.MaxContactCountQuota) { return(Error <ResultObject>(UpdateQuotasWrongQuotaError)); } if (item.MaxDistributionListCountQuota > -1 && distributionListsNumber > item.MaxDistributionListCountQuota) { return(Error <ResultObject>(UpdateQuotasWrongQuotaError)); } // get Exchange service ExchangeServerHostedEdition exchange = GetExchangeService(item.ServiceId); // update quotas exchange.UpdateOrganizationQuotas(item.Name, mailboxesNumber, contactsNumber, distributionListsNumber); return(result); } catch (Exception ex) { // log error TaskManager.WriteError(ex); // exit with error code return(Error <ResultObject>(UpdateQuotasError, ex.Message)); } finally { TaskManager.CompleteTask(); } }
private static PackageSettings GetExchangePackageSettings(ExchangeOrganization org) { // load package settings return(PackageController.GetPackageSettings(org.PackageId, PackageSettings.EXCHANGE_HOSTED_EDITION)); }
public static ResultObject SendExchangeOrganizationSummary(int itemId, string toEmail) { ResultObject result = new ResultObject(); result.IsSuccess = true; try { // initialize task manager TaskManager.StartTask(TaskManagerSource, "SEND_SUMMARY"); TaskManager.WriteParameter("Item ID", itemId); TaskManager.WriteParameter("To e-mail", toEmail); // load organization item ExchangeOrganization item = PackageController.GetPackageItem(itemId) as ExchangeOrganization; if (item == null) { return(Error <ResultObject>(OrganizationNotFoundError)); } #region Check Space and Account // Check account int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); if (accountCheck < 0) { return(Warning <ResultObject>((-accountCheck).ToString())); } // Check space int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive); if (packageCheck < 0) { return(Warning <ResultObject>((-packageCheck).ToString())); } #endregion // load organization details ExchangeOrganization org = GetOrganizationDetails(item.Id); if (org == null) { return(Error <ResultObject>(OrganizationNotFoundError)); } // get evaluated summary information MailTemplate msg = EvaluateOrganizationSummaryTemplate(org); if (msg == null) { return(Error <ResultObject>(SendOrganizationTemplateNotSetError)); } // send message int sendResult = MailHelper.SendMessage(msg.From, toEmail, msg.Bcc, msg.Subject, msg.Body, msg.Priority, msg.IsHtml); if (sendResult < 0) { return(Error <ResultObject>((-sendResult).ToString())); } return(result); } catch (Exception ex) { // log error TaskManager.WriteError(ex); // exit with error code return(Error <ResultObject>(SendOrganizationSummaryError, ex.Message)); } finally { TaskManager.CompleteTask(); } }
public static ResultObject AddOrganizationDomain(int itemId, string domainName) { ResultObject result = new ResultObject(); result.IsSuccess = true; try { // initialize task manager TaskManager.StartTask(TaskManagerSource, "ADD_DOMAIN"); TaskManager.WriteParameter("itemId", itemId); TaskManager.WriteParameter("domain", domainName); // load organization item ExchangeOrganization item = PackageController.GetPackageItem(itemId) as ExchangeOrganization; if (item == null) { return(Error <ResultObject>(OrganizationNotFoundError)); } #region Check Space and Account // Check account int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); if (accountCheck < 0) { return(Warning <ResultObject>((-accountCheck).ToString())); } // Check space int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive); if (packageCheck < 0) { return(Warning <ResultObject>((-packageCheck).ToString())); } #endregion // get organization details ExchangeOrganization org = GetOrganizationDetails(item.Id); if (org == null) { return(Error <ResultObject>(OrganizationNotFoundError)); } // check domains quota if (org.MaxDomainsCountQuota > -1 && org.Domains.Length >= org.MaxDomainsCountQuota) { return(Error <IntResult>(AddDomainQuotaExceededError)); } // check if the domain already exists DomainInfo domain = null; int checkResult = ServerController.CheckDomain(domainName); if (checkResult == BusinessErrorCodes.ERROR_DOMAIN_ALREADY_EXISTS) { // domain exists // check if it belongs to the same space domain = ServerController.GetDomain(domainName); if (domain == null) { return(Error <ResultObject>((-checkResult).ToString())); } if (domain.PackageId != org.PackageId) { return(Error <ResultObject>((-checkResult).ToString())); } // check if domain is already used in this organization foreach (ExchangeOrganizationDomain orgDomain in org.Domains) { if (String.Equals(orgDomain.Name, domainName, StringComparison.InvariantCultureIgnoreCase)) { return(Error <ResultObject>(AddDomainAlreadyUsedError)); } } } else if (checkResult == BusinessErrorCodes.ERROR_RESTRICTED_DOMAIN) { return(Error <ResultObject>((-checkResult).ToString())); } // create domain if required if (domain == null) { domain = new DomainInfo(); domain.PackageId = org.PackageId; domain.DomainName = domainName; domain.IsInstantAlias = false; domain.IsSubDomain = false; int domainId = ServerController.AddDomain(domain); if (domainId < 0) { return(Error <ResultObject>((-domainId).ToString())); } // add domain domain.DomainId = domainId; } // get Exchange service ExchangeServerHostedEdition exchange = GetExchangeService(item.ServiceId); // add domain exchange.AddOrganizationDomain(item.Name, domainName); return(result); } catch (Exception ex) { // log error TaskManager.WriteError(ex); // exit with error code return(Error <ResultObject>(AddDomainError, ex.Message)); } finally { TaskManager.CompleteTask(); } }
public static ResultObject UpdateOrganizationCatchAllAddress(int itemId, string catchAllEmail) { ResultObject result = new ResultObject(); result.IsSuccess = true; try { // initialize task manager TaskManager.StartTask(TaskManagerSource, "UPDATE_CATCHALL"); TaskManager.WriteParameter("itemId", itemId); TaskManager.WriteParameter("catchAllEmail", catchAllEmail); // load organization item ExchangeOrganization item = PackageController.GetPackageItem(itemId) as ExchangeOrganization; if (item == null) { return(Error <ResultObject>(OrganizationNotFoundError)); } #region Check Space and Account // Check account int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); if (accountCheck < 0) { return(Warning <ResultObject>((-accountCheck).ToString())); } // Check space int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive); if (packageCheck < 0) { return(Warning <ResultObject>((-packageCheck).ToString())); } #endregion // get Exchange service ExchangeServerHostedEdition exchange = GetExchangeService(item.ServiceId); // update catch-all exchange.UpdateOrganizationCatchAllAddress(item.Name, catchAllEmail); // save new catch-all in the item item.CatchAllAddress = catchAllEmail; PackageController.UpdatePackageItem(item); return(result); } catch (Exception ex) { // log error TaskManager.WriteError(ex); // exit with error code return(Error <ResultObject>(UpdateCatchAllError, ex.Message)); } finally { TaskManager.CompleteTask(); } }
public static ResultObject UpdateOrganizationServicePlan(int itemId, int newServiceId) { ResultObject result = new ResultObject(); result.IsSuccess = true; try { // initialize task manager TaskManager.StartTask(TaskManagerSource, "UPDATE_SERVICE"); TaskManager.WriteParameter("itemId", itemId); TaskManager.WriteParameter("newServiceId", newServiceId); // load organization item ExchangeOrganization item = PackageController.GetPackageItem(itemId) as ExchangeOrganization; if (item == null) { return(Error <ResultObject>(OrganizationNotFoundError)); } #region Check Space and Account // Check account int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsAdmin | DemandAccount.IsActive); if (accountCheck < 0) { return(Warning <ResultObject>((-accountCheck).ToString())); } // Check space int packageCheck = SecurityContext.CheckPackage(item.PackageId, DemandPackage.IsActive); if (packageCheck < 0) { return(Warning <ResultObject>((-packageCheck).ToString())); } #endregion // get Exchange service ExchangeServerHostedEdition exchange = GetExchangeService(item.ServiceId); // load service settings to know ProgramID, OfferID StringDictionary serviceSettings = ServerController.GetServiceSettings(newServiceId); string programId = serviceSettings["programID"]; string offerId = serviceSettings["offerID"]; // check settings if (String.IsNullOrEmpty(programId)) { result.ErrorCodes.Add(ProgramIdIsNotSetError); } if (String.IsNullOrEmpty(offerId)) { result.ErrorCodes.Add(OfferIdIsNotSetError); } // update service plan exchange.UpdateOrganizationServicePlan(item.Name, programId, offerId); // move item between services int moveResult = PackageController.MovePackageItem(itemId, newServiceId); if (moveResult < 0) { return(Error <ResultObject>((-moveResult).ToString())); } return(result); } catch (Exception ex) { // log error TaskManager.WriteError(ex); // exit with error code return(Error <ResultObject>(UpdateServicePlanError, ex.Message)); } finally { TaskManager.CompleteTask(); } }
public static IntResult CreateOrganization(int packageId, string organizationId, string domain, string adminName, string adminEmail, string adminPassword) { IntResult result = new IntResult(); result.IsSuccess = true; try { // initialize task manager TaskManager.StartTask(TaskManagerSource, "CREATE_ORGANIZATION"); TaskManager.WriteParameter("packageId", packageId); TaskManager.WriteParameter("organizationId", organizationId); TaskManager.WriteParameter("domain", domain); TaskManager.WriteParameter("adminName", adminName); TaskManager.WriteParameter("adminEmail", adminEmail); TaskManager.WriteParameter("adminPassword", adminPassword); // get Exchange service ID int serviceId = PackageController.GetPackageServiceId(packageId, ResourceGroups.ExchangeHostedEdition); if (serviceId < 1) { return(Error <IntResult>(ExchangeServiceNotEnabledError)); } #region Check Space and Account // Check account int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive); if (accountCheck < 0) { return(Warning <IntResult>((-accountCheck).ToString())); } // Check space int packageCheck = SecurityContext.CheckPackage(packageId, DemandPackage.IsActive); if (packageCheck < 0) { return(Warning <IntResult>((-packageCheck).ToString())); } #endregion // get Exchange service ExchangeServerHostedEdition exchange = GetExchangeService(serviceId); // load service settings to know ProgramID, OfferID StringDictionary serviceSettings = ServerController.GetServiceSettings(serviceId); string programId = serviceSettings["programID"]; string offerId = serviceSettings["offerID"]; // check settings if (String.IsNullOrEmpty(programId)) { result.ErrorCodes.Add(ProgramIdIsNotSetError); } if (String.IsNullOrEmpty(offerId)) { result.ErrorCodes.Add(OfferIdIsNotSetError); } if (result.ErrorCodes.Count > 0) { result.IsSuccess = false; return(result); } #region Create organization int itemId = -1; ExchangeOrganization org = null; try { // create organization exchange.CreateOrganization(organizationId, programId, offerId, domain, adminName, adminEmail, adminPassword); // save item into meta-base org = new ExchangeOrganization(); org.Name = organizationId; org.PackageId = packageId; org.ServiceId = serviceId; itemId = PackageController.AddPackageItem(org); } catch (Exception ex) { // log error TaskManager.WriteError(ex); return(Error <IntResult>(CreateOrganizationError)); } #endregion #region Update organization quotas // update max org quotas UpdateOrganizationQuotas(org); // override quotas ResultObject quotasResult = ExchangeHostedEditionController.UpdateOrganizationQuotas(itemId, org.MaxMailboxCountQuota, org.MaxContactCountQuota, org.MaxDistributionListCountQuota); if (!quotasResult.IsSuccess) { return(Error <IntResult>(quotasResult, CreateOrganizationError)); } #endregion #region Add temporary domain // load settings PackageSettings settings = GetExchangePackageSettings(org); string tempDomainTemplate = settings[TempDomainSetting]; if (!String.IsNullOrEmpty(tempDomainTemplate)) { // add temp domain string tempDomain = String.Format("{0}.{1}", domain, tempDomainTemplate); AddOrganizationDomain(itemId, tempDomain); } #endregion result.Value = itemId; return(result); } catch (Exception ex) { // log error TaskManager.WriteError(ex); // exit with error code return(Error <IntResult>(GeneralError, ex.Message)); } finally { TaskManager.CompleteTask(); } }
public static ExchangeOrganization GetOrganizationDetails(int itemId) { // load organization item ExchangeOrganization item = PackageController.GetPackageItem(itemId) as ExchangeOrganization; if (item == null) { return(null); // organization item not found } // get Exchange service ExchangeServerHostedEdition exchange = GetExchangeService(item.ServiceId); // get organization details ExchangeOrganization org = exchange.GetOrganizationDetails(item.Name); //ExchangeOrganization org = new ExchangeOrganization //{ // Id = item.Id, // PackageId = item.PackageId, // ServiceId = item.ServiceId, // Name = item.Name, // AdministratorEmail = "*****@*****.**", // AdministratorName = "Administrator Mailbox", // CatchAllAddress = "", // ContactCount = 1, // ContactCountQuota = 2, // MaxContactCountQuota = 3, // DistinguishedName = "DN=....", // DistributionListCount = 2, // DistributionListCountQuota = 3, // MaxDistributionListCountQuota = 3, // MaxDomainsCountQuota = 4, // ExchangeControlPanelUrl = "http://ecp.domain.com", // MailboxCount = 3, // MailboxCountQuota = 4, // MaxMailboxCountQuota = 4, // ProgramId = "HostedExchange", // OfferId = "2", // ServicePlan = "HostedExchange_Basic", // Domains = GetOrganizationDomains(item.Id).ToArray() //}; // update item props org.Id = item.Id; org.PackageId = item.PackageId; org.ServiceId = item.ServiceId; org.Name = item.Name; org.CatchAllAddress = item.CatchAllAddress; // update max quotas UpdateOrganizationQuotas(org); // process summary information org.SummaryInformation = GetExchangeOrganizationSummary(org); // process domains PackageSettings settings = GetExchangePackageSettings(org); if (settings != null) { // get settings string tempDomain = settings[TempDomainSetting]; string ecpUrl = settings[ExchangeControlPanelUrlSetting]; // iterate through domains foreach (ExchangeOrganizationDomain domain in org.Domains) { if (tempDomain != null && domain.Name.EndsWith("." + tempDomain, StringComparison.InvariantCultureIgnoreCase)) { domain.IsTemp = true; } if (domain.IsDefault && ecpUrl != null) { org.ExchangeControlPanelUrl = Utils.ReplaceStringVariable(ecpUrl, "domain_name", domain.Name); } } } // return org return(org); }