private void BindOrganizationDomains(ExchangeOrganization org) { try { // bind grid gvDomains.DataSource = org.Domains; gvDomains.DataBind(); // set gauge domainsQuota.QuotaValue = org.MaxDomainsCountQuota; domainsQuota.QuotaUsedValue = org.Domains.Length; } catch (Exception ex) { messageBox.ShowErrorMessage("EXCHANGE_HOSTED_GET_DOMAINS", ex); return; } }
private void BindOrganizationSummary(ExchangeOrganization org) { try { string summaryText = ES.Services.ExchangeHostedEdition.GetExchangeOrganizationSummary(org.Id); setupInstructions.Text = !String.IsNullOrEmpty(summaryText) ? summaryText : GetLocalizedString("summaryTemplateNotSet.Text"); // hide block if template is not set organizationSummary.Visible = !String.IsNullOrEmpty(summaryText) || (PanelSecurity.LoggedUser.Role != EnterpriseServer.UserRole.User); } catch (Exception ex) { messageBox.ShowErrorMessage("EXCHANGE_HOSTED_GET_DOMAINS", ex); return; } }
public ExchangeOrganization GetOrganizationDetails(string organizationId) { // get organization details ExchangeLog.LogStart("GetOrganizationDetails"); ExchangeLog.DebugInfo("organizationId: {0}", organizationId); Runspace runSpace = null; try { runSpace = OpenRunspace(); // create organization details object ExchangeOrganization org = new ExchangeOrganization { Name = organizationId }; #region Get organization details Collection <PSObject> result = GetOrganizationDetailsInternal(runSpace, organizationId); if (result.Count == 0) { ExchangeLog.LogWarning("Organization '{0}' was not found", organizationId); return(null); } PSObject objOrg = result[0]; org.DistinguishedName = (string)GetPSObjectProperty(objOrg, "DistinguishedName"); org.ServicePlan = (string)GetPSObjectProperty(objOrg, "ServicePlan"); org.ProgramId = (string)GetPSObjectProperty(objOrg, "ProgramID"); org.OfferId = (string)GetPSObjectProperty(objOrg, "OfferID"); #endregion #region Get organization quotas ExchangeLog.LogStart("Get-RecipientEnforcementProvisioningPolicy"); Command cmd = new Command("Get-RecipientEnforcementProvisioningPolicy"); cmd.Parameters.Add("Identity", String.Format("{0}\\{1}", organizationId, RecipientQuotaPolicyIdentity)); // run command result = ExecuteShellCommand(runSpace, cmd); if (result.Count == 0) { throw new NullReferenceException(String.Format("Recipient quota policy for organization '{0}' was not found", organizationId)); } PSObject objQuota = result[0]; //ExchangeLog.LogInfo(GetPSObjectProperty(objQuota, "MailboxCountQuota").GetType().ToString()); org.MailboxCountQuota = ConvertUnlimitedToInt32((Unlimited <Int32>)GetPSObjectProperty(objQuota, "MailboxCountQuota")); org.ContactCountQuota = ConvertUnlimitedToInt32((Unlimited <Int32>)GetPSObjectProperty(objQuota, "ContactCountQuota")); org.DistributionListCountQuota = ConvertUnlimitedToInt32((Unlimited <Int32>)GetPSObjectProperty(objQuota, "DistributionListCountQuota")); ExchangeLog.LogEnd("Get-RecipientEnforcementProvisioningPolicy"); #endregion #region Get organization statistics // mailboxes ExchangeLog.LogStart("Get-Mailbox"); cmd = new Command("Get-Mailbox"); cmd.Parameters.Add("Organization", organizationId); org.MailboxCount = ExecuteShellCommand(runSpace, cmd).Count; // remove system "DiscoverySearchMailbox" from statistics //if (org.MailboxCount > 0) // org.MailboxCount -= 1; ExchangeLog.LogEnd("Get-Mailbox"); // contacts ExchangeLog.LogStart("Get-Contact"); cmd = new Command("Get-Contact"); cmd.Parameters.Add("Organization", organizationId); org.ContactCount = ExecuteShellCommand(runSpace, cmd).Count; ExchangeLog.LogEnd("Get-Contact"); // distribution lists ExchangeLog.LogStart("Get-DistributionGroup"); cmd = new Command("Get-DistributionGroup"); cmd.Parameters.Add("Organization", organizationId); org.DistributionListCount = ExecuteShellCommand(runSpace, cmd).Count; ExchangeLog.LogEnd("Get-DistributionGroup"); #endregion #region Get domains org.Domains = GetOrganizationDomains(runSpace, organizationId).ToArray(); #endregion #region Administrator e-mail ExchangeLog.LogStart("Get-RoleGroupMember"); cmd = new Command("Get-RoleGroupMember"); cmd.Parameters.Add("Identity", GetOrganizationManagementGroupDN(org.DistinguishedName)); result = ExecuteShellCommand(runSpace, cmd); if (result.Count > 0) { org.AdministratorName = (string)GetPSObjectProperty(result[0], "Name"); SmtpAddress adminEmail = (SmtpAddress)GetPSObjectProperty(result[0], "PrimarySmtpAddress"); org.AdministratorEmail = (adminEmail != null) ? adminEmail.ToString() : null; } ExchangeLog.LogEnd("Get-RoleGroupMember"); #endregion ExchangeLog.LogEnd("GetOrganizationDetails"); return(org); } finally { CloseRunspace(runSpace); } }
public ExchangeOrganization GetOrganizationDetails(string organizationId) { // get organization details ExchangeLog.LogStart("GetOrganizationDetails"); ExchangeLog.DebugInfo("organizationId: {0}", organizationId); Runspace runSpace = null; try { runSpace = OpenRunspace(); // create organization details object ExchangeOrganization org = new ExchangeOrganization { Name = organizationId }; #region Get organization details Collection<PSObject> result = GetOrganizationDetailsInternal(runSpace, organizationId); if (result.Count == 0) { ExchangeLog.LogWarning("Organization '{0}' was not found", organizationId); return null; } PSObject objOrg = result[0]; org.DistinguishedName = (string)GetPSObjectProperty(objOrg, "DistinguishedName"); org.ServicePlan = (string)GetPSObjectProperty(objOrg, "ServicePlan"); org.ProgramId = (string)GetPSObjectProperty(objOrg, "ProgramID"); org.OfferId = (string)GetPSObjectProperty(objOrg, "OfferID"); #endregion #region Get organization quotas ExchangeLog.LogStart("Get-RecipientEnforcementProvisioningPolicy"); Command cmd = new Command("Get-RecipientEnforcementProvisioningPolicy"); cmd.Parameters.Add("Identity", String.Format("{0}\\{1}", organizationId, RecipientQuotaPolicyIdentity)); // run command result = ExecuteShellCommand(runSpace, cmd); if (result.Count == 0) throw new NullReferenceException(String.Format("Recipient quota policy for organization '{0}' was not found", organizationId)); PSObject objQuota = result[0]; //ExchangeLog.LogInfo(GetPSObjectProperty(objQuota, "MailboxCountQuota").GetType().ToString()); org.MailboxCountQuota = ConvertUnlimitedToInt32((Unlimited<Int32>)GetPSObjectProperty(objQuota, "MailboxCountQuota")); org.ContactCountQuota = ConvertUnlimitedToInt32((Unlimited<Int32>)GetPSObjectProperty(objQuota, "ContactCountQuota")); org.DistributionListCountQuota = ConvertUnlimitedToInt32((Unlimited<Int32>)GetPSObjectProperty(objQuota, "DistributionListCountQuota")); ExchangeLog.LogEnd("Get-RecipientEnforcementProvisioningPolicy"); #endregion #region Get organization statistics // mailboxes ExchangeLog.LogStart("Get-Mailbox"); cmd = new Command("Get-Mailbox"); cmd.Parameters.Add("Organization", organizationId); org.MailboxCount = ExecuteShellCommand(runSpace, cmd).Count; // remove system "DiscoverySearchMailbox" from statistics //if (org.MailboxCount > 0) // org.MailboxCount -= 1; ExchangeLog.LogEnd("Get-Mailbox"); // contacts ExchangeLog.LogStart("Get-Contact"); cmd = new Command("Get-Contact"); cmd.Parameters.Add("Organization", organizationId); org.ContactCount = ExecuteShellCommand(runSpace, cmd).Count; ExchangeLog.LogEnd("Get-Contact"); // distribution lists ExchangeLog.LogStart("Get-DistributionGroup"); cmd = new Command("Get-DistributionGroup"); cmd.Parameters.Add("Organization", organizationId); org.DistributionListCount = ExecuteShellCommand(runSpace, cmd).Count; ExchangeLog.LogEnd("Get-DistributionGroup"); #endregion #region Get domains org.Domains = GetOrganizationDomains(runSpace, organizationId).ToArray(); #endregion #region Administrator e-mail ExchangeLog.LogStart("Get-RoleGroupMember"); cmd = new Command("Get-RoleGroupMember"); cmd.Parameters.Add("Identity", GetOrganizationManagementGroupDN(org.DistinguishedName)); result = ExecuteShellCommand(runSpace, cmd); if (result.Count > 0) { org.AdministratorName = (string)GetPSObjectProperty(result[0], "Name"); SmtpAddress adminEmail = (SmtpAddress)GetPSObjectProperty(result[0], "PrimarySmtpAddress"); org.AdministratorEmail = (adminEmail != null) ? adminEmail.ToString() : null; } ExchangeLog.LogEnd("Get-RoleGroupMember"); #endregion ExchangeLog.LogEnd("GetOrganizationDetails"); return org; } finally { CloseRunspace(runSpace); } }