예제 #1
0
        public hMailServer.Account AddAccount(hMailServer.Accounts accounts, string sAddress, string sPassword)
        {
            hMailServer.Account oAccount = accounts.Add();
            oAccount.Address  = sAddress;
            oAccount.Password = sPassword;
            oAccount.Active   = true;
            oAccount.Save();

            return(oAccount);
        }
예제 #2
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());
        }
예제 #3
0
 public IAccount Add()
 {
     return(new Account(_object.Add()));
 }
예제 #4
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);
        }