public bool DomainExists(string domainName) { Tree config = AMSHelper.GetDomainsConfig(); AmsDomain amsDomain = new AmsDomain(domainName); return(amsDomain.Load(config)); }
public void AddDomainAlias(string domainName, string aliasName) { Tree domains = AMSHelper.GetDomainsConfig(); AmsDomain alias = new AmsDomain(aliasName); if (!alias.Load(domains)) { alias.DomainConfig["enabled"] = "1"; alias.DomainConfig["domain"] = aliasName; alias.DomainConfig["mode"] = "1"; // alias mode alias.DomainConfig["useconvertdomain"] = "1"; alias.DomainConfig["convertdomain"] = domainName; if (!alias.Save(domains)) { Log.WriteInfo("Couldn't save domains configuration."); throw new Exception("Couldn't add domain alias."); } } else { Log.WriteInfo("Alias already exists."); throw new Exception("Alias already exists."); } }
public MailDomain GetDomain(string domainName) { Tree config = AMSHelper.GetDomainsConfig(); AmsDomain amsDomain = new AmsDomain(domainName); if (amsDomain.Load(config)) { return(amsDomain.ToMailDomain()); } return(null); }
public bool DomainAliasExists(string domainName, string aliasName) { Tree config = AMSHelper.GetDomainsConfig(); AmsDomain amsAlias = new AmsDomain(aliasName); if (amsAlias.Load(config)) { if (string.Compare(amsAlias.DomainConfig["convertdomain"], domainName, true) == 0) { return(true); } } return(false); }
public void CreateDomain(MailDomain domain) { Tree domains = AMSHelper.GetDomainsConfig(); AmsDomain amsDomain = new AmsDomain(domain.Name); if (amsDomain.Load(domains)) { throw new Exception("Domain is already registered."); } amsDomain.Read(domain); if (!amsDomain.Save(domains)) { throw new Exception("Couldn't create a domain."); } }
public void DeleteDomain(string domainName) { Tree config = AMSHelper.GetDomainsConfig(); AmsDomain amsDomain = new AmsDomain(domainName); if (amsDomain.Load(config)) { if (!amsDomain.Delete(config)) { throw new Exception("Couldn't delete specified domain."); } } else { throw new Exception("Couldn't find specified domain."); } }
public void UpdateDomain(MailDomain domain) { Tree config = AMSHelper.GetDomainsConfig(); AmsDomain amsDomain = new AmsDomain(domain.Name); if (amsDomain.Load(config)) { amsDomain.Read(domain); if (!amsDomain.Save(config)) { throw new Exception("Couldn't update specified domain."); } } else { throw new Exception("Couldn't find specified domain."); } }
public void DeleteDomainAlias(string domainName, string aliasName) { Tree config = AMSHelper.GetDomainsConfig(); AmsDomain amsAlias = new AmsDomain(aliasName); if (amsAlias.Load(config)) { string amsDomain = amsAlias.DomainConfig["convertdomain"]; if (string.Compare(amsDomain, domainName, true) == 0) { if (!amsAlias.DeleteAlias(config)) { throw new Exception("Couldn't delete alias."); } } } else { throw new Exception("Couldn't find specified alias."); } }
public string[] GetDomainAliases(string domainName) { Tree config = AMSHelper.GetDomainsConfig(); return(AmsDomain.GetDomainAliases(config, domainName)); }
public virtual string[] GetDomains() { Tree config = AMSHelper.GetDomainsConfig(); return(AmsDomain.GetDomains(config)); }