protected void repeaterDomains_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Edit") { int domainID = 0; int.TryParse(e.CommandArgument.ToString(), out domainID); if (domainID > 0) { ModifyDomain(domainID); } } else if (e.CommandName == "Delete") { // Delete domain DomainsViewModel viewModel = new DomainsViewModel(); viewModel.ViewModelEvent += viewModel_ViewModelEvent; viewModel.DeleteDomain(e.CommandArgument.ToString(), WebSessionHandler.SelectedCompanyCode); // Audit AuditGlobal.AddAudit(WebSessionHandler.SelectedCompanyCode, HttpContext.Current.User.Identity.Name, ActionID.DeleteDomain, e.CommandArgument.ToString(), null); GetDomains(); } }
/// <summary> /// Gets a list of audits or returns null if it couldn't find any /// </summary> /// <param name="companyCode"></param> /// <returns></returns> public static List <Audits> GetAuditing(string companyCode) { List <Audits> audits = AuditGlobal.RetrieveAudits(companyCode); if (audits != null) { foreach (Audits a in audits) { switch (a.Action) { case Modules.Base.Enumerations.ActionID.CreateUser: a.ActionIDGlobalization = "Created new user"; break; case Modules.Base.Enumerations.ActionID.DeleteUser: a.ActionIDGlobalization = "Deleted user"; break; case Modules.Base.Enumerations.ActionID.UpdateUser: a.ActionIDGlobalization = "Updated user"; break; case Modules.Base.Enumerations.ActionID.CreateCompany: a.ActionIDGlobalization = "Created new company"; break; case Modules.Base.Enumerations.ActionID.CreateReseller: a.ActionIDGlobalization = "Created new reseller"; break; case Modules.Base.Enumerations.ActionID.SaveSettings: a.ActionIDGlobalization = "Saved settings"; break; case Modules.Base.Enumerations.ActionID.UpdateCompany: a.ActionIDGlobalization = "Updated company"; break; case Modules.Base.Enumerations.ActionID.UpdateReseller: a.ActionIDGlobalization = "Updated reseller"; break; case Modules.Base.Enumerations.ActionID.ResetPassword: a.ActionIDGlobalization = "Reset password"; break; default: break; } } } return(audits); }
private void DeleteUser(string userPrincipalName) { UsersViewModel viewModel = new UsersViewModel(); viewModel.ViewModelEvent += viewModel_ViewModelEvent; // Create new user viewModel.DeleteUser(userPrincipalName); // Audit AuditGlobal.AddAudit(WebSessionHandler.SelectedCompanyCode, HttpContext.Current.User.Identity.Name, ActionID.DeleteUser, userPrincipalName); // Refresh PopulateUsersListView(); }
protected void btnResetPwd_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtResetPwd1.Text) && !string.IsNullOrEmpty(txtResetPwd2.Text)) { if (txtResetPwd1.Text != txtResetPwd2.Text) { alertmessage.SetMessage(AlertID.WARNING, "Passwords did not match"); } else { UsersViewModel viewModel = new UsersViewModel(); viewModel.ViewModelEvent += viewModel_ViewModelEvent; viewModel.ResetPassword(hfResetPwdHiddenField.Value, txtResetPwd2.Text, WebSessionHandler.SelectedCompanyCode); AuditGlobal.AddAudit(WebSessionHandler.SelectedCompanyCode, WebSessionHandler.Username, ActionID.ResetPassword, hfResetPwdHiddenField.Value); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { // Edit an existing domain string domain = txtDomainName.Text.Trim(); bool isDefault = cbIsDefaultDomain.Checked; DomainsViewModel viewModel = new DomainsViewModel(); viewModel.ViewModelEvent += viewModel_ViewModelEvent; if (string.IsNullOrEmpty(hfDomainID.Value)) { if (cbIsAcceptedDomain.Checked && divExchangeDomain.Visible) { viewModel.AddDomain(domain, WebSessionHandler.SelectedCompanyCode, isDefault, true, GetAcceptedDomainType()); } else { viewModel.AddDomain(domain, WebSessionHandler.SelectedCompanyCode, isDefault, false, GetAcceptedDomainType()); } // Audit AuditGlobal.AddAudit(WebSessionHandler.SelectedCompanyCode, HttpContext.Current.User.Identity.Name, ActionID.AddDomain, domain, null); } else { if (cbIsAcceptedDomain.Checked && divExchangeDomain.Visible) { viewModel.UpdateDomain(domain, WebSessionHandler.SelectedCompanyCode, isDefault, cbIsAcceptedDomain.Checked, GetAcceptedDomainType()); } else { viewModel.UpdateDomain(domain, WebSessionHandler.SelectedCompanyCode, isDefault, false, GetAcceptedDomainType()); } // Audit AuditGlobal.AddAudit(WebSessionHandler.SelectedCompanyCode, HttpContext.Current.User.Identity.Name, ActionID.UpdateDomain, domain, null); } // Refresh domain list GetDomains(); }
private void SaveNewUser() { UsersObject newUser = new UsersObject(); newUser.CompanyCode = WebSessionHandler.SelectedCompanyCode; newUser.Firstname = txtFirstName.Text; newUser.Middlename = txtMiddleName.Text; newUser.Lastname = txtLastname.Text; newUser.DisplayName = txtDisplayName.Text; newUser.Department = txtDepartment.Text; newUser.UserPrincipalName = string.Format("{0}@{1}", txtLoginName.Text, ddlLoginDomain.SelectedItem.Text); newUser.Password = txtPassword1.Text; newUser.PasswordNeverExpires = cbPasswordNeverExpires.Checked; newUser.IsCompanyAdmin = cbCompanyAdmin.Checked; newUser.IsResellerAdmin = cbResellerAdmin.Checked; if (newUser.IsCompanyAdmin) { newUser.EnableExchangePerm = cbEnableExchange.Checked; newUser.DisableExchangePerm = cbDisableExchange.Checked; newUser.AddDomainPerm = cbAddDomain.Checked; newUser.DeleteDomainPerm = cbDeleteDomain.Checked; newUser.EnableAcceptedDomainPerm = cbEnableAcceptedDomain.Checked; newUser.DisableAcceptedDomainPerm = cbDisableAcceptedDomain.Checked; } UsersViewModel viewModel = new UsersViewModel(); viewModel.ViewModelEvent += viewModel_ViewModelEvent; // Create new user viewModel.CreateUser(newUser); // Audit AuditGlobal.AddAudit(WebSessionHandler.SelectedCompanyCode, HttpContext.Current.User.Identity.Name, ActionID.CreateUser, newUser.UserPrincipalName, null); // Refresh PopulateUsersListView(); }
/// <summary> /// Saves the new settings to the database /// </summary> private void SaveSettings() { try { #region General StaticSettings.HostersName = txtCompanyName.Text; StaticSettings.ResellersEnabled = cbEnableResellers.Checked; #endregion #region Active Directory StaticSettings.HostingOU = txtHostingOU.Text; StaticSettings.UsersOU = txtUsersOU.Text; StaticSettings.PrimaryDC = txtDomainController.Text; StaticSettings.Username = txtUsername.Text; StaticSettings.Password = DataProtection.Encrypt(txtPassword.Text, ConfigurationManager.AppSettings["Key"]); #endregion #region Security Groups StaticSettings.SuperAdmins = txtSuperAdmins.Text; StaticSettings.BillingAdmins = txtBillingAdmins.Text; #endregion #region Billing #endregion #region Exchange StaticSettings.ExchangeConnectionType = ddlExchConnectionType.SelectedValue; StaticSettings.ExchangeVersion = int.Parse(ddlExchVersion.SelectedValue); StaticSettings.ExchangeServer = txtExchServer.Text; StaticSettings.ExchangePublicFolderServer = txtExchPFServer.Text; StaticSettings.ExchangeDatabases = txtExchDatabases.Text; StaticSettings.PublicFoldersEnabled = cbExchPFEnabled.Checked; StaticSettings.ExchangeSSLEnabled = cbExchSSLEnabled.Checked; #endregion #region Modules StaticSettings.CitrixEnabled = cbEnableCitrix.Checked; StaticSettings.LyncEnabled = cbEnableLync.Checked; #endregion // Commit changes StaticSettings.CommitSettings(ConfigurationManager.AppSettings["Key"]); // Audit AuditGlobal.AddAudit(WebSessionHandler.SelectedCompanyCode, WebSessionHandler.Username, Modules.Base.Enumerations.ActionID.SaveSettings, "", ""); // Show Success alertmessage.SetMessage(Modules.Base.Enumerations.AlertID.SUCCESS, "Successfully saved settings"); } catch (Exception ex) { alertmessage.SetMessage(Modules.Base.Enumerations.AlertID.FAILED, ex.Message); } }