private static ExchangeMailbox GetDemoMailboxSettings()
 {
     ExchangeMailbox mb = new ExchangeMailbox();
     mb.DisplayName = "John Smith";
     mb.Domain = "HSTDEXCH1";
     mb.AccountName = "john_fabrikam";
     mb.EnableForwarding = true;
     mb.EnableIMAP = true;
     mb.EnableMAPI = true;
     mb.EnablePOP = true;
     mb.FirstName = "John";
     mb.LastName = "Smith";
     mb.ForwardingAccount = GetAccounts(0, ExchangeAccountType.Mailbox)[1];
     mb.EnableForwarding = true;
     mb.IssueWarningKB = 150000;
     mb.KeepDeletedItemsDays = 14;
     mb.LastLogoff = DateTime.Now;
     mb.LastLogon = DateTime.Now;
     mb.ManagerAccount = GetAccounts(0, ExchangeAccountType.Mailbox)[1];
     mb.MaxReceiveMessageSizeKB = 20000;
     mb.MaxRecipients = 30;
     mb.MaxSendMessageSizeKB = 10000;
     mb.ProhibitSendKB = 160000;
     mb.ProhibitSendReceiveKB = 170000;
     mb.TotalItems = 5;
     mb.TotalSizeMB = 4;
     return mb;
 }
Пример #2
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;
        }
Пример #3
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);
        }
Пример #4
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;
        }
Пример #5
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);
        }