private void BindSettings()
        {
            try
            {
                // get settings
                ExchangeDistributionList dlist = ES.Services.ExchangeServer.GetDistributionListGeneralSettings(
                    PanelRequest.ItemID, PanelRequest.AccountID);

                litDisplayName.Text = PortalAntiXSS.Encode(dlist.DisplayName);

                // bind form
                txtDisplayName.Text        = dlist.DisplayName;
                chkHideAddressBook.Checked = dlist.HideFromAddressBook;

                manager.SetAccount(dlist.ManagerAccount);

                members.SetAccounts(dlist.MembersAccounts);

                txtNotes.Text = dlist.Notes;
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("EXCHANGE_GET_DLIST_SETTINGS", ex);
            }
        }
        private void SaveSettings()
        {
            if (!Page.IsValid)
            {
                return;
            }

            try
            {
                int result = ES.Services.ExchangeServer.SetDistributionListGeneralSettings(
                    PanelRequest.ItemID, PanelRequest.AccountID,
                    txtDisplayName.Text,
                    chkHideAddressBook.Checked,

                    manager.GetAccount(),

                    members.GetAccounts(),

                    txtNotes.Text);

                if (result < 0)
                {
                    messageBox.ShowResultMessage(result);
                    return;
                }

                litDisplayName.Text = PortalAntiXSS.Encode(txtDisplayName.Text);

                messageBox.ShowSuccessMessage("EXCHANGE_UPDATE_DLIST_SETTINGS");
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("EXCHANGE_UPDATE_DLIST_SETTINGS", ex);
            }
        }
Exemplo n.º 3
0
        private void BindSettings()
        {
            try
            {
                // get settings
                OrganizationSecurityGroup securityGroup = ES.Services.Organizations.GetSecurityGroupGeneralSettings(
                    PanelRequest.ItemID, PanelRequest.AccountID);

                litDisplayName.Text = PortalAntiXSS.Encode(securityGroup.DisplayName);

                // bind form
                txtDisplayName.Text = securityGroup.DisplayName;
                lblGroupName.Text   = securityGroup.AccountName;

                members.SetAccounts(securityGroup.MembersAccounts);

                txtNotes.Text = securityGroup.Notes;

                if (securityGroup.IsDefault)
                {
                    txtDisplayName.ReadOnly = true;
                    txtNotes.ReadOnly       = true;
                    members.Enabled         = false;

                    btnSave.Visible = false;
                    tabs.IsDefault  = true;
                }
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("ORGANIZATION_GET_SECURITY_GROUP_SETTINGS", ex);
            }
        }
Exemplo n.º 4
0
        private void BindSummary()
        {
            // general
            litHostname.Text = txtVmName.Text.Trim();
            //            litHostname.Text =  PortalAntiXSS.Decode(String.Format("{0}.{1}", txtHostname.Text.Trim(), txtDomain.Text.Trim()));
            litOperatingSystem.Text = listOperatingSystems.SelectedItem.Text;

            litSummaryEmail.Text        = PortalAntiXSS.Encode(txtSummaryEmail.Text.Trim());
            SummSummaryEmailRow.Visible = chkSendSummary.Checked;

            // config
            litCpu.Text = PortalAntiXSS.Encode(ddlCpu.SelectedValue);
            litRam.Text = PortalAntiXSS.Encode(txtRam.Text.Trim());
            litHdd.Text = PortalAntiXSS.Encode(txtHdd.Text.Trim());
            //litSnapshots.Text = PortalAntiXSS.Decode(txtSnapshots.Text.Trim());
            //optionDvdInstalled.Value = chkDvdInstalled.Checked;
            //optionBootFromCd.Value = chkBootFromCd.Checked;
            //optionNumLock.Value = chkNumLock.Checked;
            optionStartShutdown.Value = chkStartShutdown.Checked;
            optionPauseResume.Value   = chkPauseResume.Checked;
            optionReboot.Value        = chkReboot.Checked;
            optionReset.Value         = chkReset.Checked;
            optionReinstall.Value     = chkReinstall.Checked;

            // external network
            optionExternalNetwork.Value = chkExternalNetworkEnabled.Checked;

            // private network
            optionPrivateNetwork.Value   = chkPrivateNetworkEnabled.Checked;
            litPrivateNetworkVLanID.Text = ddlPrivateVLanID.SelectedValue;
        }
        private void BindSettings()
        {
            try
            {
                // get settings
                ExchangeDistributionList dlist = ES.Services.ExchangeServer.GetDistributionListGeneralSettings(
                    PanelRequest.ItemID, PanelRequest.AccountID);

                litDisplayName.Text = PortalAntiXSS.Encode(dlist.DisplayName);

                ExchangeAccount[] dLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID);

                List <ExchangeAccount> groupsList = new List <ExchangeAccount>();
                foreach (ExchangeAccount distList in dLists)
                {
                    groupsList.Add(distList);
                }

                if (EnableSecurityGroups)
                {
                    ExchangeAccount[] secGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID);

                    foreach (ExchangeAccount secGroup in secGroups)
                    {
                        groupsList.Add(secGroup);
                    }
                }

                groups.SetAccounts(groupsList.ToArray());
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("EXCHANGE_GET_DLIST_SETTINGS", ex);
            }
        }
Exemplo n.º 6
0
        private void SaveSettings()
        {
            if (!Page.IsValid)
            {
                return;
            }

            try
            {
                int result = ES.Services.Organizations.SetSecurityGroupGeneralSettings(
                    PanelRequest.ItemID,
                    PanelRequest.AccountID,
                    txtDisplayName.Text,
                    members.GetAccounts(),
                    txtNotes.Text);

                if (result < 0)
                {
                    messageBox.ShowResultMessage(result);
                    return;
                }

                litDisplayName.Text = PortalAntiXSS.Encode(txtDisplayName.Text);

                messageBox.ShowSuccessMessage("ORGANIZATION_UPDATE_SECURITY_GROUP_SETTINGS");
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("ORGANIZATION_UPDATE_SECURITY_GROUP_SETTINGS", ex);
            }
        }
Exemplo n.º 7
0
        private void ExportLog()
        {
            // build HTML
            DataTable dtRecords = ES.Services.AuditLog.GetAuditLogRecordsPaged(PanelSecurity.SelectedUserId,
                                                                               PanelSecurity.PackageId, PanelRequest.ItemID, txtItemName.Text.Trim(),
                                                                               DateTime.Parse(litStartDate.Text),
                                                                               DateTime.Parse(litEndDate.Text),
                                                                               Utils.ParseInt(ddlSeverity.SelectedValue, 0),
                                                                               ddlSource.SelectedValue, ddlTask.SelectedValue,
                                                                               "StartDate ASC", 0, Int32.MaxValue).Tables[1];

            StringBuilder sb = new StringBuilder();

            // header
            sb.AppendLine("Started,Finished,Severity,User-ID,Username,Source,Task,Item-Name,Execution-Log");

            foreach (DataRow dr in dtRecords.Rows)
            {
                // Started
                sb.AppendFormat("\"{0}\",", dr["StartDate"].ToString());
                // Finished
                sb.AppendFormat("\"{0}\",", dr["FinishDate"].ToString());
                // Severity
                sb.AppendFormat("\"{0}\",",
                                GetAuditLogRecordSeverityName((int)dr["SeverityID"]));
                // User-ID
                sb.AppendFormat("\"{0}\",", dr["UserID"]);
                // Username
                sb.AppendFormat("\"{0}\",", dr["Username"]);
                // Source
                sb.AppendFormat("\"{0}\",",
                                GetAuditLogSourceName((string)dr["SourceName"]));
                // Task
                sb.AppendFormat("\"{0}\",",
                                PortalAntiXSS.Encode(GetAuditLogTaskName((string)dr["SourceName"], (string)dr["TaskName"])));
                // Item-Name
                sb.AppendFormat("\"{0}\",", PortalAntiXSS.Encode(dr["ItemName"].ToString()));
                // Execution-Log
                string executionLog = FormatPlainTextExecutionLog(
                    dr["ExecutionLog"].ToString(), DateTime.Parse(dr["StartDate"].ToString()));
                //
                executionLog = executionLog.Replace("\"", "\"\"");
                //
                sb.AppendFormat("\"{0}\"", executionLog);
                sb.AppendLine();
            }

            string cleanedPeriod = litPeriod.Text.Replace(" ", "").Replace("/", "-").Replace(",", "-");
            string fileName      = "WSP-AuditLog-" + cleanedPeriod + ".csv";

            Response.Clear();
            Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
            Response.ContentType = "application/ms-excel";

            Response.Write(sb.ToString());

            Response.End();
        }
Exemplo n.º 8
0
        private void SaveSettings()
        {
            if (!Page.IsValid)
            {
                return;
            }

            try
            {
                int result = ES.Services.ExchangeServer.SetContactGeneralSettings(
                    PanelRequest.ItemID, PanelRequest.AccountID,
                    txtDisplayName.Text,
                    txtEmail.Text,
                    chkHideAddressBook.Checked,

                    txtFirstName.Text,
                    txtInitials.Text,
                    txtLastName.Text,

                    txtAddress.Text,
                    txtCity.Text,
                    txtState.Text,
                    txtZip.Text,
                    country.Country,

                    txtJobTitle.Text,
                    txtCompany.Text,
                    txtDepartment.Text,
                    txtOffice.Text,
                    manager.GetAccount(),

                    txtBusinessPhone.Text,
                    txtFax.Text,
                    txtHomePhone.Text,
                    txtMobilePhone.Text,
                    txtPager.Text,
                    txtWebPage.Text,
                    txtNotes.Text,
                    Utils.ParseInt(ddlMAPIRichTextFormat.SelectedValue, 2 /*  UseDefaultSettings */));

                if (result < 0)
                {
                    messageBox.ShowResultMessage(result);
                    return;
                }

                litDisplayName.Text = PortalAntiXSS.Encode(txtDisplayName.Text);

                messageBox.ShowSuccessMessage("EXCHANGE_UPDATE_CONTACT_SETTINGS");
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("EXCHANGE_UPDATE_CONTACT_SETTINGS", ex);
            }
        }
Exemplo n.º 9
0
        private void BindSummary()
        {
            var resultVm = new VirtualMachine();

            // the user controls
            this.SaveSettingsControls(ref resultVm);
            this.BindSettingsControls(resultVm);

            // general
            litHostname.Text        = PortalAntiXSS.Encode(String.Format("{0}.{1}", txtHostname.Text.Trim(), txtDomain.Text.Trim()));
            litOperatingSystem.Text = listOperatingSystems.SelectedItem.Text;

            litSummaryEmail.Text        = PortalAntiXSS.Encode(txtSummaryEmail.Text.Trim());
            SummSummaryEmailRow.Visible = chkSendSummary.Checked;

            // config
            litCpu.Text               = PortalAntiXSS.Encode(ddlCpu.SelectedValue);
            litRam.Text               = PortalAntiXSS.Encode(txtRam.Text.Trim());
            litHdd.Text               = PortalAntiXSS.Encode(txtHdd.Text.Trim());
            litSnapshots.Text         = PortalAntiXSS.Encode(txtSnapshots.Text.Trim());
            optionDvdInstalled.Value  = chkDvdInstalled.Checked;
            optionBootFromCd.Value    = chkBootFromCd.Checked;
            optionNumLock.Value       = chkNumLock.Checked;
            optionStartShutdown.Value = chkStartShutdown.Checked;
            optionPauseResume.Value   = chkPauseResume.Checked;
            optionReboot.Value        = chkReboot.Checked;
            optionReset.Value         = chkReset.Checked;
            optionReinstall.Value     = chkReinstall.Checked;

            // external network
            optionExternalNetwork.Value            = chkExternalNetworkEnabled.Checked;
            SummExternalAddressesNumberRow.Visible = radioExternalRandom.Checked && chkExternalNetworkEnabled.Checked;
            litExternalAddressesNumber.Text        = PortalAntiXSS.Encode(txtExternalAddressesNumber.Text.Trim());
            SummExternalAddressesListRow.Visible   = radioExternalSelected.Checked && chkExternalNetworkEnabled.Checked;

            List <string> ipAddresses = new List <string>();

            foreach (ListItem li in listExternalAddresses.Items)
            {
                if (li.Selected)
                {
                    ipAddresses.Add(li.Text);
                }
            }
            litExternalAddresses.Text = PortalAntiXSS.Encode(String.Join(", ", ipAddresses.ToArray()));

            // private network
            optionPrivateNetwork.Value            = chkPrivateNetworkEnabled.Checked;
            SummPrivateAddressesNumberRow.Visible = radioPrivateRandom.Checked && chkPrivateNetworkEnabled.Checked && (ViewState["DHCP"] == null);
            litPrivateAddressesNumber.Text        = PortalAntiXSS.Encode(txtPrivateAddressesNumber.Text.Trim());
            SummPrivateAddressesListRow.Visible   = radioPrivateSelected.Checked && chkPrivateNetworkEnabled.Checked && (ViewState["DHCP"] == null);

            string[] privIps = Utils.ParseDelimitedString(txtPrivateAddressesList.Text, '\n', '\r', ' ', '\t');
            litPrivateAddressesList.Text = PortalAntiXSS.Encode(String.Join(", ", privIps));
        }
Exemplo n.º 10
0
        private void ShowError(Control placeholder, string message)
        {
            Label lbl = new Label();

            lbl.Text =
                PortalAntiXSS.Encode("<div style=\"height:300px;overflow:auto;\">" + message.Replace("\n", "<br>") +
                                     "</div>");
            lbl.ForeColor = Color.Red;
            lbl.Font.Bold = true;
            lbl.Font.Size = FontUnit.Point(8);
            placeholder.Controls.Add(lbl);
        }
Exemplo n.º 11
0
        private void BindSettings()
        {
            try
            {
                // get settings
                ExchangeContact contact = ES.Services.ExchangeServer.GetContactGeneralSettings(PanelRequest.ItemID,
                                                                                               PanelRequest.AccountID);

                litDisplayName.Text = PortalAntiXSS.Encode(contact.DisplayName);

                // bind form
                txtDisplayName.Text        = contact.DisplayName;
                txtEmail.Text              = contact.EmailAddress;
                chkHideAddressBook.Checked = contact.HideFromAddressBook;

                txtFirstName.Text = contact.FirstName;
                txtInitials.Text  = contact.Initials;
                txtLastName.Text  = contact.LastName;

                txtJobTitle.Text   = contact.JobTitle;
                txtCompany.Text    = contact.Company;
                txtDepartment.Text = contact.Department;
                txtOffice.Text     = contact.Office;
                manager.SetAccount(contact.ManagerAccount);

                txtBusinessPhone.Text = contact.BusinessPhone;
                txtFax.Text           = contact.Fax;
                txtHomePhone.Text     = contact.HomePhone;
                txtMobilePhone.Text   = contact.MobilePhone;
                txtPager.Text         = contact.Pager;
                txtWebPage.Text       = contact.WebPage;

                txtAddress.Text = contact.Address;
                txtCity.Text    = contact.City;
                txtState.Text   = contact.State;
                txtZip.Text     = contact.Zip;
                country.Country = contact.Country;
                txtNotes.Text   = contact.Notes;
                ddlMAPIRichTextFormat.SelectedValue = contact.UseMapiRichTextFormat.ToString();
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("EXCHANGE_GET_CONTACT_SETTINGS", ex);
            }
        }
Exemplo n.º 12
0
        private void BindExternalAddresses()
        {
            //PackageIPAddress[] ips = ES.Services.Servers.GetPackageIPAddresses(PanelSecurity.PackageId, 0, IPAddressPool.VpsExternalNetwork, "","","",0,255,true).Items;
            NetworkAdapterDetails nic = ES.Services.VPS2012.GetExternalNetworkAdapterDetails(PanelRequest.ItemID);

            hiddenTxtExternalAddressesNumber.Value = "1";
            if (nic.IPAddresses != null && nic.IPAddresses.GetLength(0) > 0)
            {
                List <string> ipAddresses = new List <string>();
                foreach (NetworkAdapterIPAddress ip in nic.IPAddresses)
                {
                    ipAddresses.Add(ip.IPAddress);
                }
                litExternalAddresses.Text    = PortalAntiXSS.Encode(String.Join(", ", ipAddresses.ToArray()));
                ExternalAddressesRow.Visible = true;
                Session[sessionIpAddresses]  = ipAddresses;
            }
        }
Exemplo n.º 13
0
        private void BindPrivateAddresses() //possible doesn't work
        {
            PrivateAddressesRow.Visible           = true;
            hiddenTxtPrivateAddressesNumber.Value = "1";
            NetworkAdapterDetails nic = ES.Services.VPS2012.GetPrivateNetworkAdapterDetails(PanelRequest.ItemID);

            if (nic.IsDHCP)
            {
                litPrivateAddresses.Text = GetLocalizedString("Automatic.Text");
            }
            else if (nic.IPAddresses != null && nic.IPAddresses.GetLength(0) > 0)
            {
                List <string> ipPrivateAddresses = new List <string>();
                foreach (NetworkAdapterIPAddress ip in nic.IPAddresses)
                {
                    ipPrivateAddresses.Add(ip.IPAddress);
                }
                litPrivateAddresses.Text = PortalAntiXSS.Encode(String.Join(", ", ipPrivateAddresses.ToArray()));
            }
        }
        private void BindSettings()
        {
            OrganizationUser user = ES.Services.Organizations.GetUserGeneralSettings(PanelRequest.ItemID,
                                                                                     PanelRequest.AccountID);

            litDisplayName.Text = PortalAntiXSS.Encode(user.DisplayName);

            txtEmailAddress.Text = user.PrimaryEmailAddress;

            txtMobile.Text = user.MobilePhone;

            var settings = ES.Services.System.GetSystemSettingsActive(SCP.SystemSettings.TWILIO_SETTINGS, false);

            bool twilioEnabled = settings != null &&
                                 !string.IsNullOrEmpty(settings.GetValueOrDefault(SCP.SystemSettings.TWILIO_ACCOUNTSID_KEY, string.Empty)) &&
                                 !string.IsNullOrEmpty(settings.GetValueOrDefault(SCP.SystemSettings.TWILIO_AUTHTOKEN_KEY, string.Empty)) &&
                                 !string.IsNullOrEmpty(settings.GetValueOrDefault(SCP.SystemSettings.TWILIO_PHONEFROM_KEY, string.Empty));

            rbtnMobile.Visible = twilioEnabled;
        }
Exemplo n.º 15
0
        private void SaveSettings()
        {
            if (!Page.IsValid)
            {
                return;
            }

            try
            {
                int result = 0;
                ExchangeDisclaimer disclaimer = new ExchangeDisclaimer();
                disclaimer.DisclaimerName = txtDisplayName.Text;
                disclaimer.DisclaimerText = txtNotes.Text;

                if (PanelRequest.AccountID == 0)
                {
                    int id = ES.Services.ExchangeServer.AddExchangeDisclaimer(PanelRequest.ItemID, disclaimer);
                }
                else
                {
                    disclaimer.ExchangeDisclaimerId = PanelRequest.AccountID;

                    result = ES.Services.ExchangeServer.UpdateExchangeDisclaimer(
                        PanelRequest.ItemID, disclaimer);
                }

                if (result < 0)
                {
                    messageBox.ShowResultMessage(result);
                    return;
                }

                litDisplayName.Text = PortalAntiXSS.Encode(txtDisplayName.Text);

                messageBox.ShowSuccessMessage("EXCHANGE_UPDATE_DISCLAIMER_SETTINGS");
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("EXCHANGE_UPDATE_DISCLAIMER_SETTINGS", ex);
            }
        }
        private void BindSettings()
        {
            try
            {
                if (PanelRequest.AccountID != 0)
                {
                    // get settings
                    ExchangeDisclaimer disclaimer = ES.Services.ExchangeServer.GetExchangeDisclaimer(
                        PanelRequest.ItemID, PanelRequest.AccountID);

                    litDisplayName.Text = PortalAntiXSS.Encode(disclaimer.DisclaimerName);

                    // bind form
                    txtDisplayName.Text = disclaimer.DisclaimerName;
                    txtNotes.Text       = disclaimer.DisclaimerText;
                }
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("EXCHANGE_GET_DISCLAIMER_SETTINGS", ex);
            }
        }
Exemplo n.º 17
0
        private void SaveSettings()
        {
            if (!Page.IsValid)
            {
                return;
            }

            try
            {
                int result = ES.Services.ExchangeServer.SetPublicFolderGeneralSettings(
                    PanelRequest.ItemID, PanelRequest.AccountID,
                    txtName.Text,
                    chkHideAddressBook.Checked,
                    allAccounts.GetAccounts());

                if (result < 0)
                {
                    messageBox.ShowResultMessage(result);
                    return;
                }

                messageBox.ShowSuccessMessage("EXCHANGE_UPDATE_PFOLDER_SETTINGS");

                // folder name
                string origName = litDisplayName.Text;
                origName = origName.Substring(0, origName.LastIndexOf("\\"));

                litDisplayName.Text = PortalAntiXSS.Encode(origName + txtName.Text);

                BindSettings();
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("EXCHANGE_UPDATE_PFOLDER_SETTINGS", ex);
            }
        }
Exemplo n.º 18
0
        private void BindSettings()
        {
            try
            {
                // get settings
                OrganizationUser user = ES.Services.Organizations.GetUserGeneralSettings(PanelRequest.ItemID,
                                                                                         PanelRequest.AccountID);

                litDisplayName.Text = PortalAntiXSS.Encode(user.DisplayName);

                lblUserDomainName.Text = user.DomainUserName;

                // bind form
                lblDisplayName.Text = user.DisplayName;

                chkDisable.Checked = user.Disabled;

                lblFirstName.Text = user.FirstName;
                lblInitials.Text  = user.Initials;
                lblLastName.Text  = user.LastName;



                lblJobTitle.Text   = user.JobTitle;
                lblCompany.Text    = user.Company;
                lblDepartment.Text = user.Department;
                lblOffice.Text     = user.Office;

                if (user.Manager != null)
                {
                    lblManager.Text = user.Manager.DisplayName;
                }

                lblBusinessPhone.Text = user.BusinessPhone;
                lblFax.Text           = user.Fax;
                lblHomePhone.Text     = user.HomePhone;
                lblMobilePhone.Text   = user.MobilePhone;
                lblPager.Text         = user.Pager;
                lblWebPage.Text       = user.WebPage;

                lblAddress.Text = user.Address;
                lblCity.Text    = user.City;
                lblState.Text   = user.State;
                lblZip.Text     = user.Zip;
                lblCountry.Text = user.Country;

                lblNotes.Text = user.Notes;
                lblExternalEmailAddress.Text = user.ExternalEmail;

                lblExternalEmailAddress.Enabled = user.AccountType == ExchangeAccountType.User;
                lblUserDomainName.Text          = user.DomainUserName;

                lblSubscriberNumber.Text  = user.SubscriberNumber;
                lblUserPrincipalName.Text = user.UserPrincipalName;

                PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
                if (cntx.Quotas.ContainsKey(Quotas.EXCHANGE2007_ISCONSUMER))
                {
                    if (cntx.Quotas[Quotas.EXCHANGE2007_ISCONSUMER].QuotaAllocatedValue != 1)
                    {
                        locSubscriberNumber.Visible = false;
                        lblSubscriberNumber.Visible = false;
                    }
                }

                if (user.LevelId > 0 && secServiceLevels.Visible)
                {
                    secServiceLevels.IsCollapsed = false;

                    ServiceLevel serviceLevel = ES.Services.Organizations.GetSupportServiceLevel(user.LevelId);

                    litServiceLevel.Visible = true;
                    litServiceLevel.Text    = serviceLevel.LevelName;
                    litServiceLevel.ToolTip = serviceLevel.LevelDescription;

                    lblServiceLevel.Text = serviceLevel.LevelName;
                }

                chkVIP.Checked     = user.IsVIP && secServiceLevels.Visible;
                imgVipUser.Visible = user.IsVIP && secServiceLevels.Visible;

                if (cntx.Quotas.ContainsKey(Quotas.ORGANIZATION_ALLOWCHANGEUPN))
                {
                    if (cntx.Quotas[Quotas.ORGANIZATION_ALLOWCHANGEUPN].QuotaAllocatedValue != 1)
                    {
                        chkInherit.Visible = false;
                    }
                    else
                    {
                        chkInherit.Visible = true;
                    }
                }

                if (user.Locked)
                {
                    chkLocked.Enabled = true;
                }
                else
                {
                    chkLocked.Enabled = false;
                }

                chkLocked.Checked = user.Locked;
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("ORGANIZATION_GET_USER_SETTINGS", ex);
            }
        }
        private void BindUserSpace()
        {
            spanSpace.Visible    = false;
            pnlViewSpace.Visible = false;
            pnlEditSpace.Visible = false;

            lnkCurrentPage.Text = PortalUtils.GetLocalizedPageName(PortalUtils.GetCurrentPageId());

            if (PanelSecurity.PackageId > 0)
            {
                // space
                PackageInfo package = ES.Services.Packages.GetPackage(PanelSecurity.PackageId);
                if (package != null)
                {
                    spanSpace.Visible    = true;
                    pnlViewSpace.Visible = true;

                    lnkSpace.Text        = PortalAntiXSS.EncodeOld(package.PackageName);
                    lnkSpace.NavigateUrl = PortalUtils.GetSpaceHomePageUrl(package.PackageId);

                    cmdSpaceName.Text        = PortalAntiXSS.EncodeOld(package.PackageName);
                    lblSpaceDescription.Text = PortalAntiXSS.EncodeOld(package.PackageComments);

                    UserInfo user = UsersHelper.GetUser(PanelSecurity.SelectedUserId);
                    if (user != null)
                    {
                        lblUserAccountName.Text = PortalAntiXSS.EncodeOld(string.Format("{0} -", user.Username));
                    }

                    lnkCurrentPage.NavigateUrl = PortalUtils.NavigatePageURL(
                        PortalUtils.GetCurrentPageId(), "SpaceID", PanelSecurity.PackageId.ToString());
                }
            }
            else
            {
                pnlViewUser.Visible = true;

                // user
                UserInfo user = UsersHelper.GetUser(PanelSecurity.SelectedUserId);
                if (user != null)
                {
                    lblUsername.Text = user.Username;

                    lnkCurrentPage.NavigateUrl = PortalUtils.NavigatePageURL(
                        PortalUtils.GetCurrentPageId(), "UserID", PanelSecurity.SelectedUserId.ToString());
                }
            }

            // organization
            bool orgVisible = (PanelRequest.ItemID > 0 && Request[DefaultPage.PAGE_ID_PARAM].Equals(PID_SPACE_EXCHANGE_SERVER, StringComparison.InvariantCultureIgnoreCase));

            spanOrgn.Visible = orgVisible;

            if (orgVisible)
            {
                // load organization details
                Organization org = ES.Services.Organizations.GetOrganization(PanelRequest.ItemID);

                lnkOrgn.NavigateUrl = PortalUtils.EditUrl(
                    "ItemID", PanelRequest.ItemID.ToString(), ORGANIZATION_CONTROL_KEY,
                    "SpaceID=" + PanelSecurity.PackageId.ToString());
                lnkOrgn.Text = org.Name;

                string curCtrlKey = PanelRequest.Ctl.ToLower();
                string ctrlKey    = PortalUtils.GetGeneralESControlKey(Request[DefaultPage.CONTROL_ID_PARAM].ToLower(System.Globalization.CultureInfo.InvariantCulture));

                if (curCtrlKey == "edit_user")
                {
                    ctrlKey = PanelRequest.Context.ToLower() == "user" ? "users" : "mailboxes";
                }

                ModuleDefinition definition = PortalConfiguration.ModuleDefinitions[EXCHANGE_SERVER_MODULE_DEFINTION_ID];
                ModuleControl    control    = null;
                if (!String.IsNullOrEmpty(ctrlKey) && definition.Controls.ContainsKey(ctrlKey))
                {
                    control = definition.Controls[ctrlKey];
                }

                if (control != null)
                {
                    if (!String.IsNullOrEmpty(control.Src))
                    {
                        lnkOrgCurPage.Text        = PortalUtils.GetLocalizedString(DM_FOLDER_VIRTUAL_PATH + control.Src, PAGE_NANE_KEY);
                        lnkOrgCurPage.NavigateUrl = PortalUtils.EditUrl(
                            "ItemID", PanelRequest.ItemID.ToString(), ctrlKey,
                            "SpaceID=" + PanelSecurity.PackageId.ToString());
                    }
                }
            }
        }
        private void BindSettings()
        {
            try
            {
                BindPasswordSettings();

                // get settings
                OrganizationUser user = ES.Services.Organizations.GetUserGeneralSettings(PanelRequest.ItemID,
                                                                                         PanelRequest.AccountID);

                litDisplayName.Text = PortalAntiXSS.Encode(user.DisplayName);

                lblUserDomainName.Text = user.DomainUserName;

                // bind form
                txtDisplayName.Text = user.DisplayName;

                chkDisable.Checked = user.Disabled;

                txtFirstName.Text = user.FirstName;
                txtInitials.Text  = user.Initials;
                txtLastName.Text  = user.LastName;



                txtJobTitle.Text   = user.JobTitle;
                txtCompany.Text    = user.Company;
                txtDepartment.Text = user.Department;
                txtOffice.Text     = user.Office;
                manager.SetAccount(user.Manager);

                txtBusinessPhone.Text = user.BusinessPhone;
                txtFax.Text           = user.Fax;
                txtHomePhone.Text     = user.HomePhone;
                txtMobilePhone.Text   = user.MobilePhone;
                txtPager.Text         = user.Pager;
                txtWebPage.Text       = user.WebPage;

                txtAddress.Text = user.Address;
                txtCity.Text    = user.City;
                txtState.Text   = user.State;
                txtZip.Text     = user.Zip;
                country.Country = user.Country;

                txtNotes.Text = user.Notes;
                txtExternalEmailAddress.Text = user.ExternalEmail;

                txtExternalEmailAddress.Enabled = user.AccountType == ExchangeAccountType.User;
                lblUserDomainName.Text          = user.DomainUserName;

                txtSubscriberNumber.Text  = user.SubscriberNumber;
                lblUserPrincipalName.Text = user.UserPrincipalName;

                PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
                if (cntx.Quotas.ContainsKey(Quotas.EXCHANGE2007_ISCONSUMER))
                {
                    if (cntx.Quotas[Quotas.EXCHANGE2007_ISCONSUMER].QuotaAllocatedValue != 1)
                    {
                        locSubscriberNumber.Visible = false;
                        txtSubscriberNumber.Visible = false;
                    }
                }

                if (user.LevelId > 0 && secServiceLevels.Visible)
                {
                    secServiceLevels.IsCollapsed = false;

                    ServiceLevel serviceLevel = ES.Services.Organizations.GetSupportServiceLevel(user.LevelId);

                    litServiceLevel.Visible = true;
                    litServiceLevel.Text    = serviceLevel.LevelName;
                    litServiceLevel.ToolTip = serviceLevel.LevelDescription;

                    bool addLevel = ddlServiceLevels.Items.FindByValue(serviceLevel.LevelId.ToString()) == null;
                    addLevel = addLevel && cntx.Quotas.ContainsKey(Quotas.SERVICE_LEVELS + serviceLevel.LevelName);
                    addLevel = addLevel ? cntx.Quotas[Quotas.SERVICE_LEVELS + serviceLevel.LevelName].QuotaAllocatedValue != 0 : addLevel;
                    if (addLevel)
                    {
                        ddlServiceLevels.Items.Add(new ListItem(serviceLevel.LevelName, serviceLevel.LevelId.ToString()));
                    }

                    bool levelInDDL = ddlServiceLevels.Items.FindByValue(serviceLevel.LevelId.ToString()) != null;

                    if (levelInDDL)
                    {
                        ddlServiceLevels.Items.FindByValue(string.Empty).Selected = false;
                        ddlServiceLevels.Items.FindByValue(serviceLevel.LevelId.ToString()).Selected = true;
                    }
                }
                chkVIP.Checked     = user.IsVIP && secServiceLevels.Visible;
                imgVipUser.Visible = user.IsVIP && secServiceLevels.Visible;


                if (cntx.Quotas.ContainsKey(Quotas.ORGANIZATION_ALLOWCHANGEUPN))
                {
                    if (cntx.Quotas[Quotas.ORGANIZATION_ALLOWCHANGEUPN].QuotaAllocatedValue != 1)
                    {
                        lblUserPrincipalName.Visible = true;
                        upn.Visible = false;
                        ddlEmailAddresses.Visible       = false;
                        btnSetUserPrincipalName.Visible = false;
                        chkInherit.Visible = false;
                    }
                    else
                    {
                        lblUserPrincipalName.Visible = false;
                        upn.Visible = false;
                        ddlEmailAddresses.Visible       = false;
                        btnSetUserPrincipalName.Visible = true;
                        chkInherit.Visible = true;
                        if (user.AccountType == ExchangeAccountType.Mailbox)
                        {
                            ddlEmailAddresses.Visible = true;
                            WebsitePanel.EnterpriseServer.ExchangeEmailAddress[] emails = ES.Services.ExchangeServer.GetMailboxEmailAddresses(PanelRequest.ItemID, PanelRequest.AccountID);

                            foreach (WebsitePanel.EnterpriseServer.ExchangeEmailAddress mail in emails)
                            {
                                ListItem li = new ListItem();
                                li.Text     = mail.EmailAddress;
                                li.Value    = mail.EmailAddress;
                                li.Selected = mail.IsPrimary;
                                ddlEmailAddresses.Items.Add(li);
                            }

                            foreach (ListItem li in ddlEmailAddresses.Items)
                            {
                                if (li.Value == user.UserPrincipalName)
                                {
                                    ddlEmailAddresses.ClearSelection();
                                    li.Selected = true;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            upn.Visible = true;
                            if (!string.IsNullOrEmpty(user.UserPrincipalName))
                            {
                                string[] Tmp = user.UserPrincipalName.Split('@');
                                upn.AccountName = Tmp[0];

                                if (Tmp.Length > 1)
                                {
                                    upn.DomainName = Tmp[1];
                                }
                            }
                        }
                    }
                }

                if (user.Locked)
                {
                    chkLocked.Enabled = true;
                }
                else
                {
                    chkLocked.Enabled = false;
                }

                chkLocked.Checked = user.Locked;

                password.ValidationEnabled = true;
                password.Password          = string.Empty;

                var settings = ES.Services.Organizations.GetWebDavSystemSettings();

                btnResetUserPassword.Visible = settings != null && Utils.ParseBool(settings[EnterpriseServer.SystemSettings.WEBDAV_PASSWORD_RESET_ENABLED_KEY], false);

                chkUserMustChangePassword.Checked = user.UserMustChangePassword;
            }
            catch (Exception ex)
            {
                messageBox.ShowErrorMessage("ORGANIZATION_GET_USER_SETTINGS", ex);
            }
        }