Example #1
0
    public static XMDomainCollection GetDomains()
    {
        XMDomainCollection xmDomains = new XMDomainCollection();
        XMLayer            xmLayer   = new XMLayer();

        try
        {
            xmLayer = XMServer.CreateXMLayer();
            xmLayer.Login();

            string domains = xmLayer.ListDomains();
            using (StringReader sr = new StringReader(domains))
            {
                string line = string.Empty;
                while ((line = sr.ReadLine()) != null)
                {
                    line = line.Trim();
                    if (line == ".")
                    {
                        break;
                    }
                    string domainName = line.Trim(new char[] { '"' });
                    xmDomains.Add(new XMDomain(domainName, domainName, AdminPanelConstants.UserType.xm));
                }
            }
            xmLayer.Logout();
        }
        catch (Exception error)
        {
            Log.WriteException(error);
            throw;
        }
        return(xmDomains);
    }
Example #2
0
    protected void InitDomain()
    {
        string[] dName      = new string[1];
        string   domainName = "";

        if (_isUpdate)
        {
            _actionDomain = "Edit Domain";
            intIncomingMailProtocol.Attributes["class"] = "wm_hide";
            ButtonSave.Visible = false;
            trForHr.Visible    = false;
            textDomainName.Attributes.Add("class", "wm_hide");

            string uid = HttpUtility.UrlDecode(this.Request.QueryString["uid"].ToString());
            SelectedValueStruct sds = AdminPanelUtils.ParseSelectedValue(uid);
            hidCustomDomain.Value = "0";
            dName[0] = sds.Name;
            string domains;

            XMLayer xmLayer = XMServer.CreateXMLayer();
            switch (sds.Type)
            {
            case AdminPanelConstants.UserType.xm:
            case AdminPanelConstants.UserType.xma:
                try
                {
                    xmLayer.Login();
                    domains = xmLayer.ListDomains(dName);
                    using (StringReader sr = new StringReader(domains))
                    {
                        string line = string.Empty;
                        while ((line = sr.ReadLine()) != null)
                        {
                            line = line.Trim();
                            if (line == ".")
                            {
                                break;
                            }
                            domainName = line.Trim(new char[] { '"' });
                        }
                    }
                    textDomainName.Value = domainName;
                }
                catch (Exception error)
                {
                    Log.WriteException(error);
                    AdminPanelUtils.SetPageErrorMessage(this.Page, error.Message);
                }
                finally
                {
                    xmLayer.Logout();
                }
                break;

            case AdminPanelConstants.UserType.xmc:

                _domainType = "vir";
                try
                {
                    xmLayer.Login();
                    domainName            = dName[0];
                    hidCustomDomain.Value = "1";
                    ButtonSave.Visible    = true;
                    trForHr.Visible       = true;
                    string DomainStringArray = XMDomain.GetCustomDomainTab(sds.Name)[0];

                    using (StringReader sr = new StringReader(DomainStringArray))
                    {
                        string[] data;
                        string   line;
//                            RedirectionsListDDL.Items.Clear();
                        LRedirectionsListDDL.Items.Clear();

                        while ((line = sr.ReadLine()) != null)
                        {
                            line = line.Trim();
                            data = XMDomain.extractCustomDomainData(line);
                            int i;
                            switch (data[0])
                            {
                            case "mailbox":
                                break;

/*
 *                                  case "redirect":
 *                                      for (i = 1; i < data.Length; i++)
 *                                          RedirectionsListDDL.Items.Add(data[i]);
 *                                      break;
 */
                            case "lredirect":
                                for (i = 1; i < data.Length; i++)
                                {
                                    LRedirectionsListDDL.Items.Add(data[i]);
                                }
                                break;
                            }
                        }
                        AdvancedID.Text      = XMDomain.GetCustomDomainTab(domainName)[1];
                        textDomainName.Value = domainName;
                    }
                }
                catch (Exception error)
                {
                    Log.WriteException(error);
                    AdminPanelUtils.SetPageErrorMessage(this.Page, error.Message);
                }
                finally
                {
                    xmLayer.Logout();
                }
                break;

            case AdminPanelConstants.UserType.wm:
                //Webmail Domains
                _domainType        = "rem";
                ButtonSave.Visible = true;
                trForHr.Visible    = true;
                try
                {
                    Domain dom = Domain.LoadFromDb(sds.Name.Trim());
                    textDomainName.Value             = dom.Name;
                    domainName                       = dom.Name;
                    txtIncomingMail.Value            = dom.MailIncomingHost;
                    intIncomingMailPort.Value        = dom.MailIncomingPort.ToString();
                    txtOutgoingMail.Value            = dom.MailOutgoingHost;
                    intOutgoingMailPort.Value        = dom.MailOutgoingPort.ToString();
                    intReqSmtpAuthentication.Checked = dom.MailOutgoingAuthentication;
                    hidWebMailDomainID.Value         = dom.ID.ToString();


                    switch (dom.MailIncomingProtocol)
                    {
                    case IncomingMailProtocol.Pop3:
                        intIncomingMailProtocol.SelectedIndex = 0;
                        break;

                    case IncomingMailProtocol.Imap4:
                        intIncomingMailProtocol.SelectedIndex = 1;
                        break;

                    default:
                        intIncomingMailProtocol.SelectedIndex = 0;
                        break;
                    }
                }
                catch (Exception error)
                {
                    Log.WriteException(error);
                    AdminPanelUtils.SaveState("SessPageErrorMessage", WebMail.Constants.mailAdmUpdateAccountUnsuccess, Page.Session);
                }
                break;
            }
            UID = HttpUtility.UrlEncode(sds.Type + "_" + domainName);

            if (AdminPanelUtils.IsSuperAdmin(Page.Session, (Page as DefaultPage).Settings))
            {
                Domain dom = new Domain();

                if (UID.Length > 0)
                {
                    try
                    {
                        SelectedValueStruct sus = AdminPanelUtils.ParseSelectedValue(uid);

                        if (sus.Type != AdminPanelConstants.UserType.xm)
                        {
                            try
                            {
                                dom = Domain.LoadFromDb(sus.Name);
                            }
                            catch { }
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.WriteException(ex);
                        AdminPanelUtils.SetPageErrorMessage(this.Page, (ex.InnerException != null ? ex.InnerException.Message : ex.Message));
                    }
                }

                if (dom != null)
                {
                    domain_filter = dom.ID.ToString();
                }
            }

            litDomainName.Text = @"<span style=""font-size: large;"">" + domainName + "</span>";

            switch (_domainType)
            {
            case "vir":
                litDomainDescription.Text = "Defines rules for forwarding mail from this domain to other addresses.";
                break;

            case "rem":
                litDomainDescription.Text = "Contains users hosted by other mail services (e.g. gmx.com).";
                break;

            default:
                litDomainDescription.Text = "Contains users hosted by this server.";
                break;
            }
        }
        else
        {
            _actionDomain = "Create Domain";

            divDomainName.Attributes["class"] = "wm_hide";

            intIncomingMailPort.Value = "110";
            intOutgoingMailPort.Value = "25";

            switch (_domainType)
            {
            case "vir":
                litDomainDescriptionView.Text = "Defines rules for forwarding mail from this domain to other addresses.";
                break;

            case "rem":
                litDomainDescriptionView.Text = "Contains users hosted by other mail services (e.g. gmx.com).";
                break;

            default:
                litDomainDescriptionView.Text = "Contains users hosted by this server.";
                break;
            }
        }
        switch (_domainType)
        {
        case "vir":
            tr_custom_options.Attributes["class"] = "";
            break;

        case "rem":
            tr_webmail_options.Attributes["class"] = "";
            break;

        default:
            tr_custom_options.Attributes["class"]  = "wm_hide";
            tr_webmail_options.Attributes["class"] = "wm_hide";
            break;
        }

        if (!AdminPanelUtils.IsSuperAdmin(Page.Session, (Page as DefaultPage).Settings))
        {
            tr_see_webmail.Attributes["class"] = "wm_hide";
        }
    }