private void PopulateEditUserView() { UsersViewModel viewModel = new UsersViewModel(); viewModel.ViewModelEvent += viewModel_ViewModelEvent; // Don't populate Exchange information if the company isn't enabled for Exchange if (CompanyChecks.IsExchangeEnabled(WebSessionHandler.SelectedCompanyCode)) { // // Populate the mailbox plans // List <MailboxPlanObject> mailboxPlans = viewModel.GetMailboxPlans(WebSessionHandler.SelectedCompanyCode); ddlEditMailboxPlan.Items.Clear(); if (mailboxPlans != null && mailboxPlans.Count > 0) { foreach (MailboxPlanObject o in mailboxPlans) { ListItem item = new ListItem(); item.Value = o.MailboxPlanID.ToString(); item.Text = o.MailboxPlanName; item.Attributes.Add("Description", o.MailboxPlanDescription); item.Attributes.Add("Min", o.MailboxSizeInMB.ToString()); item.Attributes.Add("Max", o.MaxMailboxSizeInMB.ToString()); item.Attributes.Add("Price", o.Price); item.Attributes.Add("Extra", o.AdditionalGBPrice); ddlEditMailboxPlan.Items.Add(item); } } } }
private void CheckCompany() { bool isEnabled = CompanyChecks.IsExchangeEnabled(WebSessionHandler.SelectedCompanyCode); if (isEnabled) { Response.Redirect("~/company/email/disable.aspx"); } }
private void PopulateStaticFields() { UsersViewModel viewModel = new UsersViewModel(); viewModel.ViewModelEvent += viewModel_ViewModelEvent; List <DomainsObject> foundDomains = viewModel.GetDomains(WebSessionHandler.SelectedCompanyCode); ddlLoginDomain.DataSource = foundDomains; ddlLoginDomain.DataBind(); // Don't populate Exchange information if the company isn't enabled for Exchange if (CompanyChecks.IsExchangeEnabled(WebSessionHandler.SelectedCompanyCode)) { // Get list of users List <UsersObject> users = viewModel.GetUsers(WebSessionHandler.SelectedCompanyCode); // // User Permissions dropdown boxes // // Filter only users with sAMAccountName List <UsersObject> permissionUsers = users.FindAll(x => !string.IsNullOrEmpty(x.sAMAccountName)); // Bind to list ddlEditMailboxFullAccess.DataSource = permissionUsers; ddlEditMailboxSendAs.DataSource = permissionUsers; ddlEditMailboxSendOnBehalf.DataSource = permissionUsers; ddlEditMailboxFullAccess.DataBind(); ddlEditMailboxSendAs.DataBind(); ddlEditMailboxSendOnBehalf.DataBind(); // // Populate the forward to list // ddlEditMailboxForwardTo.Items.Clear(); ddlEditMailboxForwardTo.Items.Add("Not Selected"); // // Populate the accepted domain fields // var acceptedDomains = from a in foundDomains where a.IsAcceptedDomain select a; // If we found accepted domains then we can show the email section if (acceptedDomains != null && acceptedDomains.Count() > 0) { ddlEditMailboxDomain.DataSource = acceptedDomains; ddlEditMailboxDomain.DataBind(); ddlEditAddEmailAliasDomain.DataSource = acceptedDomains; ddlEditAddEmailAliasDomain.DataBind(); } } }
private void CheckCompany() { bool isEnabled = CompanyChecks.IsExchangeEnabled(WebSessionHandler.SelectedCompanyCode); if (!isEnabled) { btnDisableExchange.Enabled = false; Response.Redirect("~/company/email/enable.aspx"); } else { btnDisableExchange.Enabled = true; } }
private void ModifyDomain(int domainID) { hfDomainID.Value = domainID.ToString(); DomainsViewModel viewModel = new DomainsViewModel(); viewModel.ViewModelEvent += viewModel_ViewModelEvent; DomainsObject domain = viewModel.GetDomain(domainID); txtDomainName.Text = domain.DomainName; cbIsDefaultDomain.Checked = domain.IsDefault; // Do not show exchange if company is not enabled if (CompanyChecks.IsExchangeEnabled(WebSessionHandler.SelectedCompanyCode)) { cbIsAcceptedDomain.Checked = domain.IsAcceptedDomain; divExchangeDomain.Visible = true; switch (domain.TypeOfDomain) { case DomainType.AuthoritativeDomain: cbAuthoritative.Checked = true; break; case DomainType.InternalRelayDomain: cbInternalRelay.Checked = true; break; case DomainType.ExternalRelayDomain: cbExternalRelay.Checked = true; break; default: cbAuthoritative.Checked = true; break; } } else { cbIsAcceptedDomain.Checked = false; divExchangeDomain.Visible = false; } txtDomainName.ReadOnly = true; panelDomainList.Visible = false; panelEditCreateDomain.Visible = true; }
private void EditUser(string userPrincipalName) { UsersViewModel viewModel = new UsersViewModel(); viewModel.ViewModelEvent += viewModel_ViewModelEvent; // // // GET USER INFORMATION // // // UsersObject user = viewModel.GetUser(userPrincipalName); if (user != null) { lbProfileDisplayName.Text = user.DisplayName; lbProfileUsername.Text = user.UserPrincipalName; lbProfileSamAccountName.Text = user.sAMAccountName; hfEditUserPrincipalName.Value = user.UserPrincipalName; txtEditFirstName.Text = user.Firstname; txtEditMiddleName.Text = user.Middlename; txtEditLastname.Text = user.Lastname; txtEditDisplayName.Text = user.DisplayName; txtEditDepartment.Text = user.Department; cbEditIsCompanyAdmin.Checked = user.IsCompanyAdmin; cbEditIsResellerAdmin.Checked = user.IsResellerAdmin; cbEditEnableUser.Checked = user.IsEnabled; cbEditAddDomain.Checked = user.AddDomainPerm; cbEditDeleteDomain.Checked = user.DeleteDomainPerm; cbEditDisableAcceptedDomain.Checked = user.DisableAcceptedDomainPerm; cbEditDisableExchange.Checked = user.DisableExchangePerm; cbEditEnableAcceptedDomain.Checked = user.EnableAcceptedDomainPerm; cbEditEnableExchange.Checked = user.EnableExchangePerm; cbEditMailboxEnableArchiving.Checked = user.ArchivePlan > 0 ? true : false; // Get the user photo imgUserPhoto.ImageUrl = string.Format("services/UserPhotoHandler.ashx?id={0}", user.UserPrincipalName); // Set view state ViewState["CPCurrentEditUser"] = user; } // // // GET MAILBOX INFORMATION // // // _isExchangeEnabled = CompanyChecks.IsExchangeEnabled(WebSessionHandler.SelectedCompanyCode); if (_isExchangeEnabled) { // Get list of accepted domains PopulateEditUserView(); // Get mailbox information if (user != null) { if (user.MailboxPlan > 0) { cbEditIsMailboxEnabled.Checked = true; MailboxPlanObject mailboxPlan = viewModel.GetMailboxPlan(user.MailboxPlan); _currentMailboxSize = mailboxPlan.MailboxSizeInMB + user.AdditionalMB; ListItem item = ddlEditMailboxPlan.Items.FindByValue(mailboxPlan.MailboxPlanID.ToString()); if (item != null) { ddlEditMailboxPlan.SelectedValue = item.Value; } UsersObject mailboxUser = viewModel.GetUserMailbox(userPrincipalName); if (mailboxUser != null) { string[] primaryEmailAddress = mailboxUser.PrimarySmtpAddress.Split('@'); // Populate email information txtEditMailboxEmail.Text = primaryEmailAddress[0]; ListItem item2 = ddlEditMailboxDomain.Items.FindByText(primaryEmailAddress[1]); if (item2 != null) { ddlEditMailboxDomain.SelectedValue = item2.Value; } // Populate email aliases emailAliases = new List <MailAliasObject>(); foreach (string s in mailboxUser.EmailAliases) { emailAliases.Add(new MailAliasObject() { Email = s }); } ViewState["CPEmailAliases"] = emailAliases; gridEmailAliases.DataSource = emailAliases; gridEmailAliases.DataBind(); // Populate forwarding if (!string.IsNullOrEmpty(mailboxUser.ForwardingTo)) { ListItem fItem = ddlEditMailboxForwardTo.Items.FindByValue(mailboxUser.ForwardingTo); if (fItem != null) { ddlEditMailboxForwardTo.SelectedValue = fItem.Value; } else { ddlEditMailboxForwardTo.SelectedIndex = -1; } } cbEditMailboxForwardBoth.Checked = mailboxUser.DeliverToMailboxAndForward; // Populate permissions if (mailboxUser.FullAccessUsers != null) { foreach (string fullAccess in mailboxUser.FullAccessUsers) { ListItem fullItem = ddlEditMailboxFullAccess.Items.FindByValue(fullAccess); if (fullItem != null) { fullItem.Selected = true; } } } if (mailboxUser.SendAsUsers != null) { foreach (string sendAs in mailboxUser.SendAsUsers) { ListItem sendAsItem = ddlEditMailboxSendAs.Items.FindByValue(sendAs); if (sendAsItem != null) { sendAsItem.Selected = true; } } } if (mailboxUser.SendOnBehalf != null) { foreach (string sendOnBehalf in mailboxUser.SendOnBehalf) { ListItem sendOnBehalfItem = ddlEditMailboxSendOnBehalf.Items.FindByValue(sendOnBehalf); if (sendOnBehalfItem != null) { sendOnBehalfItem.Selected = true; } } } // Populate litigation hold cbEditMailboxEnableLitigationHold.Checked = mailboxUser.LitigationHoldEnabled; txtEditMailboxLitigationHoldURL.Text = mailboxUser.LitigationHoldUrl; txtEditMailboxLitigationHoldComments.Text = mailboxUser.LitigationHoldComment; if (mailboxUser.LitigationHoldDuration > 0) { DateTime now = DateTime.Now.AddDays(mailboxUser.LitigationHoldDuration); txtEditMailboxLitigationHoldDuration.Text = now.ToShortDateString(); } else { txtEditMailboxLitigationHoldDuration.Text = string.Empty; } // Populate archive if (user.ArchivePlan > 0) { txtEditMailboxArchiveName.Text = mailboxUser.ArchiveName; } else { txtEditMailboxArchiveName.Text = string.Empty; } ViewState["CPCurrentEditMailbox"] = mailboxUser; } } else { cbEditIsMailboxEnabled.Checked = false; } } } // Change panels panelCreateUser.Visible = false; panelUserList.Visible = false; panelEditUser.Visible = true; }