public UserInfo(UserInfo src) { userId = src.userId; ownerId = src.ownerId; roleId = src.roleId; statusId = src.statusId; loginStatusId = src.loginStatusId; failedLogins = src.failedLogins; created = src.created; changed = src.changed; isPeer = src.isPeer; isDemo = src.isDemo; comments = src.comments; username = src.username; firstName = src.firstName; lastName = src.lastName; email = src.email; secondaryEmail = src.secondaryEmail; address = src.address; city = src.city; country = src.country; state = src.state; zip = src.zip; primaryPhone = src.primaryPhone; secondaryPhone = src.secondaryPhone; fax = src.fax; instantMessenger = src.instantMessenger; htmlMail = src.htmlMail; companyName = src.companyName; ecommerceEnabled = src.ecommerceEnabled; subscriberNumber = src.subscriberNumber; }
private void BindRoles(UserInfo user) { if (user.Role == UserRole.User) role.Items.Remove("Reseller"); if ((PanelSecurity.LoggedUser.Role == UserRole.ResellerCSR) | (PanelSecurity.LoggedUser.Role == UserRole.ResellerHelpdesk)) role.Items.Remove("Reseller"); }
public static void SetThreadSupervisorPrincipal() { UserInfo user = new UserInfo(); user.UserId = -1; user.OwnerId = 0; user.IsPeer = false; user.IsDemo = false; user.Status = UserStatus.Active; user.Role = UserRole.Administrator; SetThreadPrincipal(user); }
public override void ExecuteTrigger(TriggerEventArgs eventArgs) { // try { Contract contract = ContractSystem.ContractController.GetContract(ReferenceId); // if (contract.Status == ContractStatus.Pending) { // ContractAccount account = ContractSystem.ContractController.GetContractAccountSettings(ReferenceId); // // create user account ES.UserInfo userInfo = new ES.UserInfo(); userInfo.Username = account[ContractAccount.USERNAME]; // userInfo.Password = account[ContractAccount.PASSWORD]; userInfo.Email = account[ContractAccount.EMAIL]; userInfo.FirstName = account[ContractAccount.FIRST_NAME]; userInfo.LastName = account[ContractAccount.LAST_NAME]; userInfo.HtmlMail = (account[ContractAccount.MAIL_FORMAT] == "HTML"); userInfo.Address = account[ContractAccount.ADDRESS]; userInfo.City = account[ContractAccount.CITY]; userInfo.CompanyName = account[ContractAccount.COMPANY_NAME]; userInfo.Country = account[ContractAccount.COUNTRY]; userInfo.State = account[ContractAccount.STATE]; userInfo.PrimaryPhone = account[ContractAccount.PHONE_NUMBER]; userInfo.Fax = account[ContractAccount.FAX_NUMBER]; userInfo.InstantMessenger = account[ContractAccount.INSTANT_MESSENGER]; userInfo.Zip = account[ContractAccount.ZIP]; userInfo.Role = ES.UserRole.User; userInfo.Status = ES.UserStatus.Active; // set account parent userInfo.OwnerId = contract.ResellerId; userInfo.Created = DateTime.Now; // create account int resultCode = ES.UserController.AddUser(userInfo, true, account[ContractAccount.PASSWORD]); // if (resultCode > 0) { ContractSystem.ContractController.UpdateContract(ReferenceId, resultCode, contract.AccountName, ContractStatus.Active, 0m, contract.FirstName, contract.LastName, contract.Email, contract.CompanyName, null, null); } } } catch (Exception ex) { TriggerStatus = "ERROR"; ES.TaskManager.WriteError(ex); } }
private static List<UserInfo> GetRecentlySwitchedUsersInternal() { List<UserInfo> users = new List<UserInfo>(); // get existing list string[] pairs = GetRecentlySwitchedUsersArray(); foreach (string pair in pairs) { string[] parts = pair.Split('='); UserInfo user = new UserInfo(); user.UserId = Utils.ParseInt(parts[0], 0); user.Username = parts[1]; users.Add(user); } return users; }
public static void SetThreadPrincipal(UserInfo user) { // set roles array List<string> roles = new List<string>(); roles.Add(SecurityContext.ROLE_USER); if (user.Role == UserRole.Reseller || user.Role == UserRole.Administrator || user.Role == UserRole.PlatformHelpdesk || user.Role == UserRole.ResellerHelpdesk) roles.Add(SecurityContext.ROLE_RESELLERHELPDESK); if (user.Role == UserRole.Reseller || user.Role == UserRole.Administrator || user.Role == UserRole.PlatformCSR || user.Role == UserRole.ResellerCSR) roles.Add(SecurityContext.ROLE_RESELLERCSR); if (user.Role == UserRole.Reseller || user.Role == UserRole.Administrator || user.Role == UserRole.PlatformHelpdesk) roles.Add(SecurityContext.ROLE_PLATFORMHELPDESK); if (user.Role == UserRole.Reseller || user.Role == UserRole.Administrator || user.Role == UserRole.PlatformCSR) roles.Add(SecurityContext.ROLE_PLATFORMCSR); if (user.Role == UserRole.Reseller || user.Role == UserRole.Administrator) roles.Add(SecurityContext.ROLE_RESELLER); if (user.Role == UserRole.Administrator) roles.Add(SecurityContext.ROLE_ADMINISTRATOR); // create a new generic principal/identity and place them to context EnterpriseServerIdentity identity = new EnterpriseServerIdentity(user.UserId.ToString()); EnterpriseServerPrincipal principal = new EnterpriseServerPrincipal(identity, roles.ToArray()); principal.UserId = user.UserId; principal.OwnerId = user.OwnerId; principal.IsPeer = user.IsPeer; principal.IsDemo = user.IsDemo; principal.Status = user.Status; Thread.CurrentPrincipal = principal; }
public static int UpdateUser(int portalId, UserInfo user) { // update user in WebsitePanel int result = ES.Services.Users.UpdateUser(user); if (result < 0) return result; return 0; }
public static int AddUser(List<string> log, int portalId, UserInfo user, bool sendLetter, string password) { // add user to WebsitePanel server return ES.Services.Users.AddUser(user, sendLetter, password); }
private void PopulateCustomers(DataNode parentNode) { UserInfo info = parentNode.Tag as UserInfo; DataSet ds = null; try { ds = UserController.GetRawUsers(info.UserId, false); } catch(Exception ex) { ShowError("Unable to load users.", ex); } if (ds != null) { foreach (DataRow dr in ds.Tables[0].Rows) { UserInfo user = new UserInfo(); user.UserId = Utils.GetDbInt32(dr["UserId"]); user.Username = Utils.GetDbString(dr["Username"]); user.RoleId = Utils.GetDbInt32(dr["RoleId"]); AddTreeNode(parentNode, user.Username, 0, USER, user, true); } } }
public static int UpdateUserAsync(string taskId, UserInfo user) { UserAsyncWorker usersWorker = new UserAsyncWorker(); usersWorker.ThreadUserId = SecurityContext.User.UserId; usersWorker.TaskId = taskId; usersWorker.User = user; usersWorker.UpdateUserAsync(); return 0; }
public int UpdateUserLiteral(int userId, int roleId, int statusId, bool isPeer, bool isDemo, string firstName, string lastName, string email, string secondaryEmail, string address, string city, string country, string state, string zip, string primaryPhone, string secondaryPhone, string fax, string instantMessenger, bool htmlMail, string companyName, bool ecommerceEnabled) { UserInfo user = new UserInfo(); user.UserId = userId; user.RoleId = roleId; user.StatusId = statusId; user.IsPeer = isPeer; user.IsDemo = isDemo; user.FirstName = firstName; user.LastName = lastName; user.Email = email; user.SecondaryEmail = secondaryEmail; user.Address = address; user.City = city; user.Country = country; user.State = state; user.Zip = zip; user.PrimaryPhone = primaryPhone; user.SecondaryPhone = secondaryPhone; user.Fax = fax; user.InstantMessenger = instantMessenger; user.HtmlMail = htmlMail; user.CompanyName = companyName; user.EcommerceEnabled = ecommerceEnabled; return UserController.UpdateUser(user); }
public int UpdateUserTaskAsynchronously(string taskId, UserInfo user) { return UserController.UpdateUserAsync(taskId, user); }
public int AddUser(UserInfo user, bool sendLetter) { return UserController.AddUser(user, sendLetter); }
private void SendMailMessage(UserInfo user, IEnumerable<DomainDnsChanges> domainsChanges, Dictionary<int, UserInfo> domainUsers) { BackgroundTask topTask = TaskManager.TopTask; UserSettings settings = UserController.GetUserSettings(user.UserId, UserSettings.DOMAIN_LOOKUP_LETTER); string from = settings["From"]; var bcc = settings["CC"]; string subject = settings["Subject"]; MailPriority priority = MailPriority.Normal; if (!String.IsNullOrEmpty(settings["Priority"])) priority = (MailPriority)Enum.Parse(typeof(MailPriority), settings["Priority"], true); // input parameters string mailTo = (string)topTask.GetParamValue("MAIL_TO"); string body = string.Empty; bool isHtml = user.HtmlMail; if (domainsChanges.Any()) { body = user.HtmlMail ? settings["HtmlBody"] : settings["TextBody"]; } else { body = user.HtmlMail ? settings["NoChangesHtmlBody"] : settings["NoChangesTextBody"]; } Hashtable items = new Hashtable(); items["user"] = user; items["DomainUsers"] = domainUsers; items["Domains"] = domainsChanges; body = PackageController.EvaluateTemplate(body, items); // send mail message MailHelper.SendMessage(from, mailTo, bcc, subject, body, priority, isHtml); }
public override void ExecuteTrigger(TriggerEventArgs eventArgs) { // try { Contract contract = ContractSystem.ContractController.GetContract(ReferenceId); // if (contract.Status == ContractStatus.Pending) { // ContractAccount account = ContractSystem.ContractController.GetContractAccountSettings(ReferenceId); // // create user account ES.UserInfo userInfo = new ES.UserInfo(); userInfo.Username = account[ContractAccount.USERNAME]; userInfo.Password = account[ContractAccount.PASSWORD]; userInfo.Email = account[ContractAccount.EMAIL]; userInfo.FirstName = account[ContractAccount.FIRST_NAME]; userInfo.LastName = account[ContractAccount.LAST_NAME]; userInfo.HtmlMail = (account[ContractAccount.MAIL_FORMAT] == "HTML"); userInfo.Address = account[ContractAccount.ADDRESS]; userInfo.City = account[ContractAccount.CITY]; userInfo.CompanyName = account[ContractAccount.COMPANY_NAME]; userInfo.Country = account[ContractAccount.COUNTRY]; userInfo.State = account[ContractAccount.STATE]; userInfo.PrimaryPhone = account[ContractAccount.PHONE_NUMBER]; userInfo.Fax = account[ContractAccount.FAX_NUMBER]; userInfo.InstantMessenger = account[ContractAccount.INSTANT_MESSENGER]; userInfo.Zip = account[ContractAccount.ZIP]; userInfo.Role = ES.UserRole.User; userInfo.Status = ES.UserStatus.Active; // set account parent userInfo.OwnerId = contract.ResellerId; userInfo.Created = DateTime.Now; // create account int resultCode = ES.UserController.AddUser(userInfo, true); // if (resultCode > 0) { ContractSystem.ContractController.UpdateContract(ReferenceId, resultCode, contract.AccountName, ContractStatus.Active, 0m, contract.FirstName, contract.LastName, contract.Email, contract.CompanyName, null, null); } } } catch (Exception ex) { TriggerStatus = "ERROR"; ES.TaskManager.WriteError(ex); } }
private void SaveUser() { // get owner UserInfo owner = PanelSecurity.SelectedUser; if (Page.IsValid) { // gather data from form UserInfo user = new UserInfo(); user.UserId = PanelRequest.PeerID; user.RoleId = owner.RoleId; user.StatusId = owner.StatusId; user.OwnerId = owner.UserId; user.IsDemo = owner.IsDemo; user.IsPeer = true; // account info user.FirstName = Server.HtmlEncode(txtFirstName.Text); user.LastName = Server.HtmlEncode(txtLastName.Text); user.Email = txtEmail.Text; user.SecondaryEmail = txtSecondaryEmail.Text; user.HtmlMail = ddlMailFormat.SelectedIndex == 1; user.Username = txtUsername.Text; user.Password = userPassword.Password; user.IsDemo = chkDemo.Checked; // contact info user.CompanyName = contact.CompanyName; user.Address = contact.Address; user.City = contact.City; user.Country = contact.Country; user.State = contact.State; user.Zip = contact.Zip; user.PrimaryPhone = contact.PrimaryPhone; user.SecondaryPhone = contact.SecondaryPhone; user.Fax = contact.Fax; user.InstantMessenger = contact.MessengerId; if (PanelRequest.PeerID == 0) { // add a new peer List<string> log = new List<string>(); try { //int userId = UsersHelper.AddUser(log, PortalId, user); int userId = PortalUtils.AddUserAccount(log, user, false); if (userId < 0) { ShowResultMessage(userId); return; } } catch (Exception ex) { ShowErrorMessage("PEER_ADD_PEER", ex); return; } // show lof records if any if (log.Count > 0) { blLog.Items.Clear(); foreach (string error in log) blLog.Items.Add(error); return; } } else { // update existing user try { //int result = UsersHelper.UpdateUser(PortalId, user); int result = PortalUtils.UpdateUserAccount(user); if (result < 0) { ShowResultMessage(result); return; } } catch (Exception ex) { ShowErrorMessage("PEER_UPDATE_PEER", ex); return; } } // return back to the list RedirectBack(); } }
public static ContractAccount GetContractAccountSettings(string contractId, bool internally) { // ContractAccount account = new ContractAccount(); // IDataReader dr = null; // try { int customerId = -1; dr = EcommerceProvider.GetContract(contractId); // if (dr.Read()) { string propertyNames = Convert.ToString(dr["PropertyNames"]); string propertyValues = Convert.ToString(dr["PropertyValues"]); if (dr["CustomerID"] != DBNull.Value) { customerId = Convert.ToInt32(dr["CustomerID"]); } else { SecurityUtils.DeserializeGenericProfile(propertyNames, propertyValues, account); } } // if (customerId > -1) { ES.UserInfo userInfo = (internally) ? ES.UserController.GetUserInternally(customerId) : ES.UserController.GetUser(customerId); // if (internally) { account[ContractAccount.PASSWORD] = userInfo.Password; } // account[ContractAccount.USERNAME] = userInfo.Username; account[ContractAccount.FIRST_NAME] = userInfo.FirstName; account[ContractAccount.LAST_NAME] = userInfo.LastName; account[ContractAccount.EMAIL] = userInfo.Email; account[ContractAccount.COMPANY_NAME] = userInfo.CompanyName; account[ContractAccount.COUNTRY] = userInfo.Country; account[ContractAccount.CITY] = userInfo.City; account[ContractAccount.ADDRESS] = userInfo.Address; account[ContractAccount.FAX_NUMBER] = userInfo.Fax; account[ContractAccount.INSTANT_MESSENGER] = userInfo.InstantMessenger; account[ContractAccount.PHONE_NUMBER] = userInfo.PrimaryPhone; account[ContractAccount.STATE] = userInfo.State; account[ContractAccount.ZIP] = userInfo.Zip; account[ContractAccount.MAIL_FORMAT] = userInfo.HtmlMail ? "HTML" : "PlainText"; } } catch (Exception ex) { throw ex; } finally { if (dr != null) { dr.Close(); } } // return(account); }
public static int UpdateUser(string taskId, UserInfo user) { try { // start task TaskManager.StartTask(taskId, "USER", "UPDATE", user.Username); TaskManager.ItemId = user.UserId; // check account int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo); if (accountCheck < 0) return accountCheck; UserInfo currentUser = GetUser(user.UserId); //prevent downgrade reseller with child accounts to user role if (currentUser.RoleId.Equals(2)) { if (user.RoleId.Equals(3)) { // check if user has child accounts (It happens when Reseller has child accounts and admin changes his role to User) if (GetUsers(currentUser.UserId, false).Count > 0) return BusinessErrorCodes.ERROR_USER_HAS_USERS; } } // only administrators can set admin role if (!SecurityContext.User.IsInRole(SecurityContext.ROLE_ADMINISTRATOR) && user.Role == UserRole.Administrator) user.Role = UserRole.User; // check integrity when creating a user account if (user.Role == UserRole.User) user.EcommerceEnabled = false; //// task progress //int maxSteps = 100; //TaskManager.IndicatorMaximum = maxSteps; //for (int i = 0; i < maxSteps; i++) //{ // TaskManager.Write(String.Format("Step {0} of {1}", i, maxSteps)); // TaskManager.IndicatorCurrent = i; // System.Threading.Thread.Sleep(1000); //} DataProvider.UpdateUser( SecurityContext.User.UserId, user.UserId, user.RoleId, user.StatusId, user.IsDemo, user.IsPeer, user.Comments, user.FirstName, user.LastName, user.Email, user.SecondaryEmail, user.Address, user.City, user.Country, user.State, user.Zip, user.PrimaryPhone, user.SecondaryPhone, user.Fax, user.InstantMessenger, user.HtmlMail, user.CompanyName, user.EcommerceEnabled); return 0; } catch (System.Threading.ThreadAbortException ex) { TaskManager.WriteError(ex, "The process has been terminated by the user."); return 0; } catch (Exception ex) { throw TaskManager.WriteError(ex); } finally { TaskManager.CompleteTask(); } }
public int AddUser(UserInfo user, bool sendLetter, string password) { return UserController.AddUser(user, sendLetter, password); }
private void SendMailMessage(UserInfo user, IEnumerable<DomainInfo> domains, Dictionary<int, UserInfo> domainUsers, IEnumerable<DomainInfo> nonExistenDomains, bool includeNonExistenDomains) { BackgroundTask topTask = TaskManager.TopTask; UserSettings settings = UserController.GetUserSettings(user.UserId, UserSettings.DOMAIN_EXPIRATION_LETTER); string from = settings["From"]; var bcc = settings["CC"]; string subject = settings["Subject"]; string body = user.HtmlMail ? settings["HtmlBody"] : settings["TextBody"]; bool isHtml = user.HtmlMail; MailPriority priority = MailPriority.Normal; if (!String.IsNullOrEmpty(settings["Priority"])) priority = (MailPriority)Enum.Parse(typeof(MailPriority), settings["Priority"], true); // input parameters string mailTo = (string)topTask.GetParamValue("MAIL_TO"); Hashtable items = new Hashtable(); items["user"] = user; items["Domains"] = domains.Select(x => new { DomainName = x.DomainName, ExpirationDate = x.ExpirationDate < DateTime.Now ? "Expired" : x.ExpirationDate.ToString(), ExpirationDateOrdering = x.ExpirationDate, Registrar = x.RegistrarName, Customer = string.Format("{0} {1}", domainUsers[x.PackageId].FirstName, domainUsers[x.PackageId].LastName) }) .OrderBy(x => x.ExpirationDateOrdering).ThenBy(x => x.Customer).ThenBy(x => x.DomainName); items["IncludeNonExistenDomains"] = includeNonExistenDomains; items["NonExistenDomains"] = nonExistenDomains.Select(x => new { DomainName = x.DomainName, Customer = string.Format("{0} {1}", domainUsers[x.PackageId].FirstName, domainUsers[x.PackageId].LastName) }).OrderBy(x => x.Customer).ThenBy(x => x.DomainName); body = PackageController.EvaluateTemplate(body, items); // send mail message MailHelper.SendMessage(from, mailTo, bcc, subject, body, priority, isHtml); }
public int UpdateUserTask(string taskId, UserInfo user) { return UserController.UpdateUser(taskId, user); }
private void SaveUser() { if (!Page.IsValid) return; // gather data from form UserInfo user = new UserInfo(); user.UserId = 0; user.Role = (UserRole)Enum.Parse(typeof(UserRole), role.SelectedValue); user.StatusId = Int32.Parse(status.SelectedValue); user.OwnerId = PanelSecurity.SelectedUserId; user.IsDemo = chkDemo.Checked; user.IsPeer = false; // if (chkEcommerceEnbl.Visible) user.EcommerceEnabled = chkEcommerceEnbl.Checked; // account info user.FirstName = txtFirstName.Text; user.LastName = txtLastName.Text; user.Email = txtEmail.Text; user.SecondaryEmail = txtSecondaryEmail.Text; user.HtmlMail = ddlMailFormat.SelectedIndex == 1; user.Username = txtUsername.Text.Trim(); user.Password = userPassword.Password; // contact info user.CompanyName = contact.CompanyName; user.Address = contact.Address; user.City = contact.City; user.Country = contact.Country; user.State = contact.State; user.Zip = contact.Zip; user.PrimaryPhone = contact.PrimaryPhone; user.SecondaryPhone = contact.SecondaryPhone; user.Fax = contact.Fax; user.InstantMessenger = contact.MessengerId; // add a new user List<string> log = new List<string>(); try { //int userId = UsersHelper.AddUser(log, PortalId, user); int userId = PortalUtils.AddUserAccount(log, user, chkAccountLetter.Checked); if (userId == BusinessErrorCodes.ERROR_INVALID_USER_NAME) { ShowResultMessage(BusinessErrorCodes.ERROR_INVALID_USER_NAME); return; } if (userId < 0) { ShowResultMessage(userId); return; } // show log records if any if (log.Count > 0) { blLog.Items.Clear(); foreach (string error in log) blLog.Items.Add(error); return; } // go to user home Response.Redirect(PortalUtils.GetUserHomePageUrl(userId)); } catch (Exception ex) { ShowErrorMessage("USER_ADD_USER", ex); return; } }
public int UpdateUser(UserInfo user) { return UserController.UpdateUser(user); }
private static void GetExchangeRetentionPolicyTagsByUser(int itemId, UserInfo user, ref List<ExchangeRetentionPolicyTag> retentionPolicyTags) { if ((user != null)) { List<Organization> orgs = null; if (user.UserId != 1) { List<PackageInfo> Packages = PackageController.GetPackages(user.UserId); if ((Packages != null) & (Packages.Count > 0)) { orgs = GetExchangeOrganizationsInternal(Packages[0].PackageId, false); } } else { orgs = GetExchangeOrganizationsInternal(1, false); } int OrgId = -1; if (itemId > 0) OrgId = itemId; else if ((orgs != null) & (orgs.Count > 0)) OrgId = orgs[0].Id; if (OrgId != -1) { List<ExchangeRetentionPolicyTag> RetentionPolicy = ObjectUtils.CreateListFromDataReader<ExchangeRetentionPolicyTag>(DataProvider.GetExchangeRetentionPolicyTags(OrgId)); foreach (ExchangeRetentionPolicyTag p in RetentionPolicy) { retentionPolicyTags.Add(p); } } UserInfo owner = UserController.GetUserInternally(user.OwnerId); GetExchangeRetentionPolicyTagsByUser(0, owner, ref retentionPolicyTags); } }
private void SaveUser() { if (Page.IsValid) { // gather data from form UserInfo user = new UserInfo(); user.UserId = PanelSecurity.SelectedUserId; user.Role = (UserRole)Enum.Parse(typeof(UserRole), role.SelectedValue); user.IsDemo = chkDemo.Checked; user.Status = ViewState[UserStatusConst] != null ? (UserStatus) ViewState[UserStatusConst]: UserStatus.Active; user.LoginStatusId = loginStatus.SelectedIndex; // account info user.FirstName = txtFirstName.Text; user.LastName = txtLastName.Text; user.SubscriberNumber = txtSubscriberNumber.Text; user.Email = txtEmail.Text; user.SecondaryEmail = txtSecondaryEmail.Text; user.HtmlMail = ddlMailFormat.SelectedIndex == 1; // contact info user.CompanyName = contact.CompanyName; user.Address = contact.Address; user.City = contact.City; user.Country = contact.Country; user.State = contact.State; user.Zip = contact.Zip; user.PrimaryPhone = contact.PrimaryPhone; user.SecondaryPhone = contact.SecondaryPhone; user.Fax = contact.Fax; user.InstantMessenger = contact.MessengerId; // update existing user try { int result = PortalUtils.UpdateUserAccount(/*TaskID, */user); //int result = ES.Services.Users.UpdateUserTaskAsynchronously(TaskID, user); AsyncTaskID = TaskID; if (result.Equals(-102)) { if (user.RoleId.Equals(3)) { ShowResultMessage(result); return; } } else { if (result < 0) { ShowResultMessage(result); return; } } } catch (Exception ex) { ShowErrorMessage("USER_UPDATE_USER", ex); return; } // return back to the list RedirectAccountHomePage(); } }
public static int UpdateUser(UserInfo user) { return UpdateUser(null, user); }
private void BindRoles(UserInfo user) { if (user.Role == UserRole.User) role.Items.Remove("Reseller"); }
public static int UpdateUserAccount(UserInfo user) { return UpdateUserAccount(null, user); }
private static void GetExchangeMailboxPlansByUser(int itemId, UserInfo user, ref List<ExchangeMailboxPlan> mailboxPlans, ref int? defaultPlanId, bool archiving) { if ((user != null)) { List<Organization> orgs = null; if (user.UserId != 1) { List<PackageInfo> Packages = PackageController.GetPackages(user.UserId); if ((Packages != null) & (Packages.Count > 0)) { orgs = GetExchangeOrganizationsInternal(Packages[0].PackageId, false); } } else { orgs = GetExchangeOrganizationsInternal(1, false); } int OrgId = -1; if (itemId > 0) OrgId = itemId; else if ((orgs != null) & (orgs.Count > 0)) OrgId = orgs[0].Id; if (OrgId != -1) { List<ExchangeMailboxPlan> Plans = ObjectUtils.CreateListFromDataReader<ExchangeMailboxPlan>(DataProvider.GetExchangeMailboxPlans(OrgId, archiving)); foreach (ExchangeMailboxPlan p in Plans) { mailboxPlans.Add(p); } // Set default plan ExchangeOrganization exchangeOrg = ObjectUtils.FillObjectFromDataReader<ExchangeOrganization>(DataProvider.GetExchangeOrganization(OrgId)); // If the default plan has not been set by the setting of higher priority if (!defaultPlanId.HasValue && exchangeOrg != null && exchangeOrg.ExchangeMailboxPlanID > 0) { defaultPlanId = exchangeOrg.ExchangeMailboxPlanID; } } UserInfo owner = UserController.GetUserInternally(user.OwnerId); GetExchangeMailboxPlansByUser(0, owner, ref mailboxPlans, ref defaultPlanId, archiving); } }
public static int UpdateUserAccount(string taskId, UserInfo user) { esUsers usersService = new esUsers(); ConfigureEnterpriseServerProxy(usersService, true); try { // update user in WebsitePanel return usersService.UpdateUserTask(taskId, user); } catch (Exception ex) { throw ex; } }
private int AddUser(string loginName, string password, string firstName, string lastName, string email) { try { Log.WriteStart("Adding user account"); UserInfo user = new UserInfo(); user.UserId = 0; user.Role = UserRole.User; user.StatusId = 1; user.OwnerId = 1; user.IsDemo = false; user.IsPeer = false; user.HtmlMail = true; user.Username = loginName; user.Password = password; user.FirstName = firstName; user.LastName = lastName; user.Email = email; int userId = ES.Services.Users.AddUser(user, false); if (userId > 0) { Log.WriteEnd("Added user account"); } else { Log.WriteError(string.Format("Enterprise Server error: {0}", userId)); } return userId; } catch (Exception ex) { if (!Utils.IsThreadAbortException(ex)) Log.WriteError("User configuration error", ex); return -1; } }
public static int AddUserAccount(List<string> log, UserInfo user, bool sendLetter, string password) { esUsers usersService = new esUsers(); ConfigureEnterpriseServerProxy(usersService, true); try { // add user to WebsitePanel server return usersService.AddUser(user, sendLetter, password); } catch (Exception ex) { throw ex; } }