public void Create(ExchMailbox mailbox)
        {
            if (string.IsNullOrEmpty(mailbox.Domain))
            {
                throw new Exception("Mailbox domain not defined. [" + _log.Name + "]");
            }


            ExchContext _context = ExchManager.Instance.Config.GetContext(mailbox.Domain);
            if(_context == null)
            {
                throw new Exception("Exchange context not defined for domain <" + mailbox.Domain + ">. [" + _log.Name + "]");
            }
            mailbox.Context = _context;


            string _database = ExchManager.Instance.Config.GetDatabase(mailbox);
            if (string.IsNullOrEmpty(_database))
            {
                throw new Exception("Mailbox database not defined. [" + _log.Name + "]");
            }
            mailbox.Database = _database;

            PSCommand _command = new PSCommand();
            _command.AddCommand("Enable-Mailbox");
            _command.AddParameter("Identity", mailbox.Identity);
            _command.AddParameter("DomainController", mailbox.Context.Pdc);
            _command.AddParameter("Database", _database);

            Collection<PSObject> _result = ExchManager.Instance.InvokeCommand(_command, _context);

            foreach(PSObject _rec in _result)
            {
                if (_rec.Properties["PrimarySmtpAddress"] != null)
                {
                    mailbox.Address = _rec.Properties["PrimarySmtpAddress"].Value.ToString();
                }
            }
        }
Пример #2
0
 public string GetDatabase(ExchMailbox mailbox)
 {
     return GetDatabase(mailbox.Context, mailbox.Type);
 }
Пример #3
0
 internal void UpdateModel(User user, ExchMailbox mailbox)
 {
     user.Email = mailbox.Address;
 }