public MailDomain GetDomain(string domainName) { try { svcDomainAdmin domains = new svcDomainAdmin(); PrepareProxy(domains); DomainSettingsResult result = domains.GetDomainSettings(AdminUsername, AdminPassword, domainName); if (!result.Result) throw new Exception(result.Message); // fill domain properties MailDomain domain = new MailDomain(); domain.Name = domainName; domain.Path = result.Path; domain.ServerIP = result.ServerIP; domain.ImapPort = result.ImapPort; domain.SmtpPort = result.SmtpPort; domain.PopPort = result.PopPort; domain.MaxAliases = result.MaxAliases; domain.MaxDomainAliases = result.MaxDomainAliases; domain.MaxLists = result.MaxLists; domain.MaxDomainSizeInMB = result.MaxDomainSizeInMB; domain.MaxDomainUsers = result.MaxDomainUsers; domain.MaxMailboxSizeInMB = result.MaxMailboxSizeInMB; domain.MaxMessageSize = result.MaxMessageSize; domain.MaxRecipients = result.MaxRecipients; domain.RequireSmtpAuthentication = result.RequireSmtpAuthentication; domain.ListCommandAddress = result.ListCommandAddress; domain.ShowContentFilteringMenu = result.ShowContentFilteringMenu; domain.ShowDomainAliasMenu = result.ShowDomainAliasMenu; domain.ShowListMenu = result.ShowListMenu; domain.ShowSpamMenu = result.ShowSpamMenu; // get additional domain settings string[] requestedSettings = new string[] { "catchall", "enablepopretrieval", "enablecatchalls", "isenabled", "ldapport", "altsmtpport", "sharedcalendar", "sharedcontact", "sharedfolder", "sharednotes", "sharedtasks", "sharedgal", "bypassforwardblacklist", "showdomainreports", "spamresponderoption", "spamforwardoption", "maxmessagesperhour", "maxmessagesperhourenabled", "maxsmtpoutbandwidthperhour", "maxsmtpoutbandwidthperhourenabled", "maxpopretrievalaccounts", "maxbouncesreceivedperhour", "maxbouncesreceivedperhourenabled", "enableimapretrieval", "enablemailsigning", "enableemailreports", "syncml" }; SettingsRequestResult addResult = domains.GetRequestedDomainSettings(AdminUsername, AdminPassword, domainName, requestedSettings); if (!addResult.Result) throw new Exception(addResult.Message); FillMailDomainFields(domain, addResult); // get catch-all address if (!String.IsNullOrEmpty(domain.CatchAllAccount)) { // get catch-all group string groupName = SYSTEM_CATCH_ALL + "@" + domain.Name; if (GroupExists(groupName)) { // get the first member of this group MailGroup group = GetGroup(groupName); domain.CatchAllAccount = GetAccountName(group.Members[0]); } } svcServerAdmin serverAdmin = new svcServerAdmin(); PrepareProxy(serverAdmin); EditionResult licenseType = serverAdmin.GetEdition(AdminUsername, AdminPassword); if (licenseType.Edition == "PRO") { domain[MailDomain.SMARTERMAIL_LICENSE_TYPE] = "PRO"; } if (licenseType.Edition == "ENT") { domain[MailDomain.SMARTERMAIL_LICENSE_TYPE] = "ENT"; } if (licenseType.Edition == "FREE") { domain[MailDomain.SMARTERMAIL_LICENSE_TYPE] = "FREE"; } return domain; } catch (Exception ex) { throw new Exception("Could not get mail domain", ex); } }
/// <summary> /// Checks whether the specified domain exists /// </summary> /// <param name="domainName">Domain name</param> /// <returns>true if the specified domain exists, otherwise false</returns> public bool DomainExists(string domainName) { try { svcDomainAdmin domains = new svcDomainAdmin(); PrepareProxy(domains); DomainSettingsResult result = domains.GetDomainSettings(AdminUsername, AdminPassword, domainName); return result.Result; } catch (Exception ex) { throw new Exception("Could not check whether mail domain exists", ex); } }