Beispiel #1
0
        public bool DomainExists(string domainName)
        {
            Tree      config    = AMSHelper.GetDomainsConfig();
            AmsDomain amsDomain = new AmsDomain(domainName);

            return(amsDomain.Load(config));
        }
Beispiel #2
0
        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.");
            }
        }
Beispiel #3
0
        public MailDomain GetDomain(string domainName)
        {
            Tree      config    = AMSHelper.GetDomainsConfig();
            AmsDomain amsDomain = new AmsDomain(domainName);

            if (amsDomain.Load(config))
            {
                return(amsDomain.ToMailDomain());
            }

            return(null);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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.");
            }
        }
Beispiel #6
0
        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.");
            }
        }
Beispiel #7
0
        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.");
            }
        }
Beispiel #8
0
        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.");
            }
        }
Beispiel #9
0
        public string[] GetDomainAliases(string domainName)
        {
            Tree config = AMSHelper.GetDomainsConfig();

            return(AmsDomain.GetDomainAliases(config, domainName));
        }
Beispiel #10
0
        public virtual string[] GetDomains()
        {
            Tree config = AMSHelper.GetDomainsConfig();

            return(AmsDomain.GetDomains(config));
        }