Exemple #1
0
        private void ListUsers()
        {
            EnableDomainsAndList(true);

            if (comboDomains.Items.Count == 0)
            {
                return;
            }

            listItems.Items.Clear();

            int domainID = Convert.ToInt32(comboDomains.SelectedValue);


            hMailServer.Domain   domain   = APICreator.GetDomain(domainID);
            hMailServer.Accounts accounts = domain.Accounts;

            for (int i = 0; i < accounts.Count; i++)
            {
                hMailServer.Account account = accounts[i];

                ListViewItem item = listItems.Items.Add(account.Address);
                item.Tag = account.ID;

                Marshal.ReleaseComObject(account);
            }

            Marshal.ReleaseComObject(accounts);
            Marshal.ReleaseComObject(domain);
        }
        public bool SaveData()
        {
            bool newObject = false;

            if (representedObject == null)
            {
                hMailServer.Domain domain = APICreator.GetDomain(_domainID);

                hMailServer.DistributionLists lists = domain.DistributionLists;
                representedObject = lists.Add();
                newObject         = true;

                Marshal.ReleaseComObject(lists);
                Marshal.ReleaseComObject(domain);
            }

            representedObject.Address = textAddress.Text;
            representedObject.Active  = checkEnabled.Checked;

            if (radioModePublic.Checked)
            {
                representedObject.Mode = eDistributionListMode.eLMPublic;
            }

            if (radioModeMembership.Checked)
            {
                representedObject.Mode = eDistributionListMode.eLMMembership;
            }

            if (optModeAnnouncements.Checked)
            {
                representedObject.Mode = eDistributionListMode.eLMAnnouncement;
            }

            representedObject.RequireSenderAddress = textRequireAddress.Text;
            representedObject.RequireSMTPAuth      = checkRequireSMTPAuthentication.Checked;

            representedObject.Save();

            // Refresh the node in the tree if the name has changed.
            IMainForm mainForm = Instances.MainForm;

            mainForm.RefreshCurrentNode(textAddress.Text);

            // Set the object to clean.
            DirtyChecker.SetClean(this);

            if (newObject)
            {
                SearchNodeText crit = new SearchNodeText(representedObject.Address);
                mainForm.SelectNode(crit);
            }

            EnableDisableTabs();

            return(true);
        }
Exemple #3
0
        public hMailServer.Domain GetDomain()
        {
            hMailServer.Domain domain = null;
            if (_representedObjectID > 0)
            {
                domain = APICreator.GetDomain(_representedObjectID);
            }

            return(domain);
        }
Exemple #4
0
        internal void OnAddADAccount(object sender, EventArgs e)
        {
            formActiveDirectoryAccounts accountsDlg = new formActiveDirectoryAccounts();

            if (accountsDlg.ShowDialog() == DialogResult.OK)
            {
                hMailServer.Domain   domain   = APICreator.GetDomain(_domainID);
                hMailServer.Accounts accounts = domain.Accounts;

                Instances.MainForm.Cursor = Cursors.WaitCursor;

                string        domainName   = accountsDlg.DomainName;
                List <string> accountNames = accountsDlg.AccountNames;

                foreach (string accountName in accountNames)
                {
                    try
                    {
                        hMailServer.Account account = accounts.Add();

                        account.IsAD       = true;
                        account.ADDomain   = domainName;
                        account.ADUsername = accountName;
                        account.Active     = true;

                        string address = accountName;
                        address         = address.Replace(" ", ".");
                        address         = address + "@" + domain.Name;
                        account.Address = address;

                        account.Save();

                        Marshal.ReleaseComObject(account);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, EnumStrings.hMailServerAdministrator);
                    }
                }

                Marshal.ReleaseComObject(domain);
                Marshal.ReleaseComObject(accounts);

                Instances.MainForm.Cursor = Cursors.Default;
            }

            IMainForm mainForm = Instances.MainForm;

            mainForm.RefreshCurrentNode(null);

            mainForm.ShowItem(mainForm.GetCurrentNode());
        }
Exemple #5
0
        protected override void DeleteItems(List <ListViewItem> items)
        {
            hMailServer.Domain   domain   = APICreator.GetDomain(_domainID);
            hMailServer.Accounts accounts = domain.Accounts;

            foreach (ListViewItem item in items)
            {
                int accountID = Convert.ToInt32(item.Tag);
                accounts.DeleteByDBID(accountID);
            }

            Marshal.ReleaseComObject(domain);
            Marshal.ReleaseComObject(accounts);
        }
        protected override void DeleteItems(List <ListViewItem> items)
        {
            hMailServer.Domain            domain = APICreator.GetDomain(_domainID);
            hMailServer.DistributionLists lists  = domain.DistributionLists;

            foreach (var item in items)
            {
                int listID = Convert.ToInt32(item.Tag);
                lists.DeleteByDBID(listID);
            }

            Marshal.ReleaseComObject(lists);
            Marshal.ReleaseComObject(domain);
        }
Exemple #7
0
        protected override void LoadList()
        {
            listAccounts.Items.Clear();

            hMailServer.Domain domain = APICreator.GetDomain(_domainID);

            hMailServer.Accounts accounts = domain.Accounts;

            for (int i = 0; i < accounts.Count; i++)
            {
                hMailServer.Account account = accounts[i];
                ListViewItem        item    = listAccounts.Items.Add(account.Address);
                item.SubItems.Add(EnumStrings.GetYesNoString(account.Active));
                item.Tag = account.ID;

                Marshal.ReleaseComObject(account);
            }

            Marshal.ReleaseComObject(domain);
            Marshal.ReleaseComObject(accounts);
        }
Exemple #8
0
        public bool SaveData()
        {
            bool newObject = false;

            if (representedObject == null)
            {
                hMailServer.Domain domain = APICreator.GetDomain(_domainID);

                hMailServer.Aliases aliases = domain.Aliases;
                representedObject = aliases.Add();
                newObject         = true;

                Marshal.ReleaseComObject(domain);
                Marshal.ReleaseComObject(aliases);
            }


            representedObject.Name   = textName.Text;
            representedObject.Value  = textValue.Text;
            representedObject.Active = checkEnabled.Checked;

            representedObject.Save();

            // Refresh the node in the tree if the name has changed.
            IMainForm mainForm = Instances.MainForm;

            mainForm.RefreshCurrentNode(representedObject.Name);

            // Set the object to clean.
            DirtyChecker.SetClean(this);

            if (newObject)
            {
                SearchNodeText crit = new SearchNodeText(representedObject.Name);
                mainForm.SelectNode(crit);
            }

            return(true);
        }
Exemple #9
0
        public ucAlias(int domainID, int aliasID)
        {
            InitializeComponent();

            _domainID = domainID;

            hMailServer.Domain domain = APICreator.GetDomain(domainID);

            if (aliasID > 0)
            {
                hMailServer.Aliases aliases = domain.Aliases;
                representedObject = aliases.get_ItemByDBID(aliasID);
                Marshal.ReleaseComObject(aliases);
            }

            textName.Text = "@" + domain.Name;
            Marshal.ReleaseComObject(domain);

            DirtyChecker.SubscribeToChange(this, OnContentChanged);

            new TabOrderManager(this).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst);
        }
Exemple #10
0
        public bool SaveData()
        {
            if (!ValidateForm())
            {
                return(false);
            }


            bool newAccount = false;

            if (_representedAccount == null)
            {
                hMailServer.Domain domain = APICreator.GetDomain(_domainID);

                hMailServer.Accounts accounts = domain.Accounts;
                _representedAccount = accounts.Add();

                Marshal.ReleaseComObject(accounts);
                Marshal.ReleaseComObject(domain);
            }

            if (_representedAccount.ID == 0)
            {
                newAccount = true;
            }

            _representedAccount.Address = textAddress.Text;
            _representedAccount.MaxSize = textMaxSize.Number;
            _representedAccount.Active  = checkEnabled.Checked;

            _representedAccount.VacationMessageIsOn        = checkVacationMessageEnable.Checked;
            _representedAccount.VacationSubject            = textVacationMessageSubject.Text;
            _representedAccount.VacationMessage            = textVacationMessageText.Text;
            _representedAccount.VacationMessageExpires     = checkVacationMessageExpires.Checked;
            _representedAccount.VacationMessageExpiresDate = dateVacationMessageExpiresDate.FormattedValue;

            _representedAccount.ForwardEnabled      = checkForwardEnabled.Checked;
            _representedAccount.ForwardAddress      = textForwardAddress.Text;
            _representedAccount.ForwardKeepOriginal = checkForwardKeepOriginal.Checked;

            _representedAccount.SignatureEnabled   = checkSignatureEnabled.Checked;
            _representedAccount.SignaturePlainText = textSignaturePlainText.Text;
            _representedAccount.SignatureHTML      = textSignatureHTML.Text;

            _representedAccount.IsAD       = checkAccountIsAD.Checked;
            _representedAccount.ADDomain   = textADDomain.Text;
            _representedAccount.ADUsername = textADUsername.Text;

            _representedAccount.PersonFirstName = textFirstName.Text;
            _representedAccount.PersonLastName  = textLastName.Text;
            _representedAccount.AdminLevel      = (hMailServer.eAdminLevel)comboAdministrationLevel.SelectedValue;

            if (textPassword.Dirty)
            {
                _representedAccount.Password = textPassword.Password;
            }

            _representedAccount.Save();

            // Refresh the node in the tree if the name has changed.
            IMainForm mainForm = Instances.MainForm;

            mainForm.RefreshCurrentNode(_representedAccount.Address);

            // Set the object to clean.
            DirtyChecker.SetClean(this);

            if (newAccount)
            {
                SearchNodeText crit = new SearchNodeText(_representedAccount.Address);
                mainForm.SelectNode(crit);
            }
            else
            {
                EnableDisable();
            }

            return(true);
        }