Example #1
0
        internal override ExchangeMailbox GetMailboxGeneralSettingsInternal(string accountName)
        {
            ExchangeLog.LogStart("GetMailboxGeneralSettingsInternal");
            ExchangeLog.DebugInfo("Account: {0}", accountName);

            ExchangeMailbox info = new ExchangeMailbox();

            info.AccountName = accountName;
            Runspace runSpace = null;

            try
            {
                runSpace = OpenRunspace();

                Collection <PSObject> result = GetMailboxObject(runSpace, accountName);
                PSObject mailbox             = result[0];

                string         id    = GetResultObjectDN(result);
                string         path  = AddADPrefix(id);
                DirectoryEntry entry = GetADObject(path);


                //ADAccountOptions userFlags = (ADAccountOptions)entry.Properties["userAccountControl"].Value;
                //info.Disabled = ((userFlags & ADAccountOptions.UF_ACCOUNTDISABLE) != 0);
                info.Disabled = (bool)entry.InvokeGet("AccountDisabled");

                info.DisplayName          = (string)GetPSObjectProperty(mailbox, "DisplayName");
                info.HideFromAddressBook  = (bool)GetPSObjectProperty(mailbox, "HiddenFromAddressListsEnabled");
                info.EnableLitigationHold = (bool)GetPSObjectProperty(mailbox, "LitigationHoldEnabled");

                Command cmd = new Command("Get-User");
                cmd.Parameters.Add("Identity", accountName);
                result = ExecuteShellCommand(runSpace, cmd);
                PSObject user = result[0];

                info.FirstName = (string)GetPSObjectProperty(user, "FirstName");
                info.Initials  = (string)GetPSObjectProperty(user, "Initials");
                info.LastName  = (string)GetPSObjectProperty(user, "LastName");

                info.Address    = (string)GetPSObjectProperty(user, "StreetAddress");
                info.City       = (string)GetPSObjectProperty(user, "City");
                info.State      = (string)GetPSObjectProperty(user, "StateOrProvince");
                info.Zip        = (string)GetPSObjectProperty(user, "PostalCode");
                info.Country    = CountryInfoToString((CountryInfo)GetPSObjectProperty(user, "CountryOrRegion"));
                info.JobTitle   = (string)GetPSObjectProperty(user, "Title");
                info.Company    = (string)GetPSObjectProperty(user, "Company");
                info.Department = (string)GetPSObjectProperty(user, "Department");
                info.Office     = (string)GetPSObjectProperty(user, "Office");


                info.ManagerAccount = GetManager(entry); //GetExchangeAccount(runSpace, ObjToString(GetPSObjectProperty(user, "Manager")));
                info.BusinessPhone  = (string)GetPSObjectProperty(user, "Phone");
                info.Fax            = (string)GetPSObjectProperty(user, "Fax");
                info.HomePhone      = (string)GetPSObjectProperty(user, "HomePhone");
                info.MobilePhone    = (string)GetPSObjectProperty(user, "MobilePhone");
                info.Pager          = (string)GetPSObjectProperty(user, "Pager");
                info.WebPage        = (string)GetPSObjectProperty(user, "WebPage");
                info.Notes          = (string)GetPSObjectProperty(user, "Notes");
            }
            finally
            {
                CloseRunspace(runSpace);
            }
            ExchangeLog.LogEnd("GetMailboxGeneralSettingsInternal");
            return(info);
        }
Example #2
0
        internal override ExchangeMailbox GetMailboxAdvancedSettingsInternal(string accountName)
        {
            ExchangeLog.LogStart("GetMailboxAdvancedSettingsInternal");
            ExchangeLog.DebugInfo("Account: {0}", accountName);

            ExchangeMailbox info = new ExchangeMailbox();

            info.AccountName = accountName;
            Runspace runSpace = null;

            try
            {
                runSpace = OpenRunspace();

                Collection <PSObject> result = GetMailboxObject(runSpace, accountName);
                PSObject mailbox             = result[0];

                info.IssueWarningKB =
                    ConvertUnlimitedToKB((Unlimited <ByteQuantifiedSize>)GetPSObjectProperty(mailbox, "IssueWarningQuota"));
                info.ProhibitSendKB =
                    ConvertUnlimitedToKB((Unlimited <ByteQuantifiedSize>)GetPSObjectProperty(mailbox, "ProhibitSendQuota"));
                info.ProhibitSendReceiveKB =
                    ConvertUnlimitedToKB((Unlimited <ByteQuantifiedSize>)GetPSObjectProperty(mailbox, "ProhibitSendReceiveQuota"));
                info.KeepDeletedItemsDays =
                    ConvertEnhancedTimeSpanToDays((EnhancedTimeSpan)GetPSObjectProperty(mailbox, "RetainDeletedItemsFor"));

                info.EnableLitigationHold = (bool)GetPSObjectProperty(mailbox, "LitigationHoldEnabled");

                info.RecoverabelItemsSpace =
                    ConvertUnlimitedToKB((Unlimited <ByteQuantifiedSize>)GetPSObjectProperty(mailbox, "RecoverableItemsQuota"));
                info.RecoverabelItemsWarning =
                    ConvertUnlimitedToKB((Unlimited <ByteQuantifiedSize>)GetPSObjectProperty(mailbox, "RecoverableItemsWarningQuota"));


                //Client Access
                Command cmd = new Command("Get-CASMailbox");
                cmd.Parameters.Add("Identity", accountName);
                result  = ExecuteShellCommand(runSpace, cmd);
                mailbox = result[0];

                info.EnableActiveSync = (bool)GetPSObjectProperty(mailbox, "ActiveSyncEnabled");
                info.EnableOWA        = (bool)GetPSObjectProperty(mailbox, "OWAEnabled");
                info.EnableMAPI       = (bool)GetPSObjectProperty(mailbox, "MAPIEnabled");
                info.EnablePOP        = (bool)GetPSObjectProperty(mailbox, "PopEnabled");
                info.EnableIMAP       = (bool)GetPSObjectProperty(mailbox, "ImapEnabled");

                //Statistics
                cmd = new Command("Get-MailboxStatistics");
                cmd.Parameters.Add("Identity", accountName);
                result = ExecuteShellCommand(runSpace, cmd);
                if (result.Count > 0)
                {
                    PSObject statistics = result[0];
                    Unlimited <ByteQuantifiedSize> totalItemSize =
                        (Unlimited <ByteQuantifiedSize>)GetPSObjectProperty(statistics, "TotalItemSize");
                    info.TotalSizeMB = ConvertUnlimitedToMB(totalItemSize);
                    uint?itemCount = (uint?)GetPSObjectProperty(statistics, "ItemCount");
                    info.TotalItems = ConvertNullableToInt32(itemCount);
                    DateTime?lastLogoffTime = (DateTime?)GetPSObjectProperty(statistics, "LastLogoffTime");;
                    DateTime?lastLogonTime  = (DateTime?)GetPSObjectProperty(statistics, "LastLogonTime");;
                    info.LastLogoff = ConvertNullableToDateTime(lastLogoffTime);
                    info.LastLogon  = ConvertNullableToDateTime(lastLogonTime);
                }
                else
                {
                    info.TotalSizeMB = 0;
                    info.TotalItems  = 0;
                    info.LastLogoff  = DateTime.MinValue;
                    info.LastLogon   = DateTime.MinValue;
                }

                //domain
                info.Domain = GetNETBIOSDomainName();
            }
            finally
            {
                CloseRunspace(runSpace);
            }
            ExchangeLog.LogEnd("GetMailboxAdvancedSettingsInternal");
            return(info);
        }