/// <summary> /// Handles the Click event of the ok button control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void OK_Click(object sender, EventArgs e) { AddUserOptions options = GetOptions(); IList <IUser> list = UserManagementService.AddUsers(options); if (list.Count > 1) { StringBuilder sb = new StringBuilder(); int index = 0; int count = list.Count; foreach (IUser user in list) { index++; sb.AppendFormat(index == count ? "'{0}'" : "'{0}',", user.Id); } IGroupContextService srv = ApplicationContext.Current.Services.Get <IGroupContextService>() as GroupContextService; if (srv != null) { string tableName = "USERSECURITY"; srv.CurrentTable = tableName; EntityGroupInfo currentEntityGroupInfo = srv.GetGroupContext().CurrentGroupInfo; currentEntityGroupInfo.LookupTempGroup.ClearConditions(); currentEntityGroupInfo.LookupTempGroup.AddLookupCondition(string.Format("{0}:UserId", tableName), " IN ", string.Format("({0})", sb)); currentEntityGroupInfo.LookupTempGroup.GroupXML = GroupInfo.RebuildGroupXML(currentEntityGroupInfo.LookupTempGroup.GroupXML); srv.CurrentGroupID = GroupContext.LookupResultsGroupID; } Response.Redirect(string.Format("~/{0}.aspx?", "User"), false); } else { Response.Redirect(string.Format("~/{0}.aspx?entityId={1}", "User", list[0].Id), false); } }
/// <summary> /// Initializes a new instance of the <see cref="AddUserOptionsRequest"/> class. /// </summary> /// <param name="options">The options model to make a contract out of.</param> public AddUserOptionsRequest(AddUserOptions options) : this() { if (options == null) { return; } this.EndDate = options.EndDate; this.IncludeMfaList = options.IncludeMfaList; this.IncludePending = options.IncludePending; this.LoginOnly = options.LoginOnly; this.StartDate = options.StartDate; this.Webhook = options.WebhookUri?.ToString(); }
private AddUserOptions GetOptions() { AddUserOptions options = new AddUserOptions(); UserTypeInfo info = UserTypeInfo.GetTypeInfoFromCode(lbxUserType.SelectedValue); options.UserType = info.UserType; if (String.IsNullOrEmpty(ddlQuantity.SelectedValue)) { options.Quantity = 1; } else { options.Quantity = System.Convert.ToInt32(ddlQuantity.SelectedValue); } if (chkCreateFromProfile.Checked) { options.CreateFromProfile = true; if (rdoProfileFrom.SelectedValue == "U") { if (string.IsNullOrEmpty(lueAddUser.LookupResultValue.ToString())) { throw new ValidationException(GetLocalResourceObject("lueAddUser.Validate").ToString()); } options.TemplateID = lueAddUser.LookupResultValue.ToString(); } else { options.TemplateID = lbxTemplates.SelectedValue; } } else { options.CreateFromProfile = false; options.TemplateID = string.Empty; } options.UseGeneralProfile = chkGeneral.Checked; options.UseEmployeeProfile = chkEmployee.Checked; options.UseCalendarProfile = chkCalender.Checked; options.UseClientOptionsProfile = chkClientOptions.Checked; options.UseSecurityProfile = chkSecurity.Checked; options.UseSupportProfile = chkServiceAndSupport.Checked; options.UseTeamsProfile = chkTeams.Checked; return(options); }
private void CopyProfileToSelectedUsers() { try { AddUserOptions options = copyProfileParameter.UserOptions; options.TemplateID = copyProfileParameter.SelectedUserId; foreach (var targetUser in _selUsers) { IUser sourceUser = EntityFactory.GetById <IUser>(options.TemplateID); sourceUser.UpdateWithExistingProfile(targetUser, options); targetUser.Save(); } } finally { btnOk.Enabled = true; btnCancel.Enabled = true; } }
private AddUserOptions SetAddUserOptions(IUser existingUser) { AddUserOptions options = new AddUserOptions(); options.TemplateID = existingUser.Id.ToString(); options.Quantity = 1; options.CreateFromProfile = true; options.UseCalendarProfile = true; options.UseClientOptionsProfile = true; options.UseCustomProfile = true; options.UseEmployeeProfile = true; options.UseFunctionSecurityProfile = true; options.UseGeneralProfile = true; options.UseSecurityProfile = true; options.UserType = existingUser.Type; options.UseSecurityProfile = true; options.UseTeamsProfile = true; options.UseSyncProfile = true; options.UseSupportProfile = true; return(options); }
public async Task AddUserListCodeAuth() { IHttpClientWrapper httpClient = this.GetMockHttpClient("DeviceListMfa.json", HttpStatusCode.Created, HttpMethod.Post); IPlaidClient testClient = this.GetPlaidClient(httpClient); AddUserOptions options = new AddUserOptions { IncludeMfaList = true }; AddUserResult result = await testClient.AddUserAsync(BaseTestClass.TestUsername, BaseTestClass.TestPassword, InstitutionType.Chase, options); Assert.IsNotNull(result); Assert.IsFalse(result.IsError); Assert.IsTrue(result.IsMfaRequired); Assert.AreEqual(AuthType.Code, result.AuthPrompt.AuthType); Assert.IsNotNull(result.AuthPrompt.CodeDeliveryOptions); Assert.AreEqual(2, result.AuthPrompt.CodeDeliveryOptions.Count); Assert.IsFalse(string.IsNullOrWhiteSpace(result.AuthPrompt.CodeDeliveryOptions[0].Mask)); Assert.AreEqual(DeliveryType.Phone, result.AuthPrompt.CodeDeliveryOptions[0].Type); Assert.IsFalse(string.IsNullOrWhiteSpace(result.AuthPrompt.CodeDeliveryOptions[1].Mask)); Assert.AreEqual(DeliveryType.Email, result.AuthPrompt.CodeDeliveryOptions[1].Type); }
/// <inheritdoc /> public async Task <AddUserResult> AddUserAsync(string username, string password, InstitutionType institution, AddUserOptions options = null, string pin = null, ApiType api = ApiType.Connect) { Condition.Requires(username).IsNotNullOrWhiteSpace(); Condition.Requires(password).IsNotNullOrWhiteSpace(); Condition.Requires(institution).IsNotNull(); AddUserRequest userRequest = new AddUserRequest(this.clientId, this.clientSecret) { Username = username, Password = password, Type = institution.Value, Options = new AddUserOptionsRequest(options), Pin = pin }; HttpResponseMessage response = await this.httpClient.PostAsJsonAsync(GetEndpoint(api), userRequest); return(await this.ProcessAddOrAuthResponse(response)); }
private AddUserOptions SetAddUserOptions(IUser existingUser) { AddUserOptions options = new AddUserOptions(); options.TemplateID = existingUser.Id.ToString(); options.Quantity = 1; options.CreateFromProfile = true; options.UseCalendarProfile = true; options.UseClientOptionsProfile = true; options.UseCustomProfile = true; options.UseEmployeeProfile = true; options.UseFunctionSecurityProfile = true; options.UseGeneralProfile = true; options.UseSecurityProfile = true; options.UserType = existingUser.Type; options.UseSecurityProfile = true; options.UseTeamsProfile = true; options.UseSyncProfile = true; options.UseSupportProfile = true; return options; }
private void CopySelectedUsers(IList <string> targetUserIds) { var ums = ApplicationContext.Current.Services.Get <IUserManagementService>(); IList <IUser> newUserList = new List <IUser>(); var userManagementSvc = ApplicationContext.Current.Services.Get <IUserManagementService>(); try { foreach (string id in targetUserIds) { IUser existingUser = EntityFactory.GetById <IUser>(id); if (existingUser != null && existingUser.UserInfo != null) { if (existingUser.Type == UserType.Retired) { throw new Sage.Platform.Application.ValidationException(GetLocalResourceObject("ErrorCannotCopyRetiredUser").ToString()); } AddUserOptions options = SetAddUserOptions(existingUser); // create the new user with default data IUser newUser = ums.AddUser("", options); // sometimes the copy of... name is too long for the data type string nameFormat = " {0}, {1}"; if (string.IsNullOrEmpty(existingUser.UserInfo.FirstName)) { nameFormat = " {0}{1}"; } string fullNameFormat = string.Concat("(", GetLocalResourceObject("CopyOfNameTemplate").ToString(), nameFormat, ")"); string newName = string.Format(fullNameFormat, existingUser.UserInfo.LastName, existingUser.UserInfo.FirstName); /* the following could be used to improve the user experience, but it doesn't match the lan product */ //string copyOfTemplate = GetLocalResourceObject("CopyOfNameTemplate").ToString(); //string fullNameFormat = string.Concat("<", copyOfTemplate, nameFormat, ">"); //string newLastName = existingUser.UserInfo.LastName; //if (newLastName.Contains(string.Concat("<", copyOfTemplate))) //{ // Match match = Regex.Match(newLastName, string.Concat("<", copyOfTemplate, "(.*)", ">"), RegexOptions.IgnoreCase); // if (match.Groups.Count > 0) // newLastName = match.Groups[1].Value; //} //string newName = string.Format(fullNameFormat, newLastName, existingUser.UserInfo.FirstName); newUser.UserInfo.LastName = newName.Length > 32 ? newName.Substring(0, 32) : newName; newUser.UserInfo.UserName = newName.Length > 64 ? newName.Substring(0, 64) : newName; string userTemplate = existingUser.UserInfo.UserName; newUser.UserTemplate = userTemplate.Length > 30 ? userTemplate.Substring(0, 30) : userTemplate; newUser.Save(); if (newUser != null) { newUserList.Add(newUser); } } if (newUserList.Count > 0) { LinkHandler linkHandler = new LinkHandler(Page); linkHandler.RedirectToNewGroupDetail(newUserList); } } } catch (ValidationException) { throw; } catch (Exception exp) { string sSlxErrorId = null; var sMsg = ErrorHelper.GetClientErrorHtmlMessage(exp, ref sSlxErrorId); if (!string.IsNullOrEmpty(sSlxErrorId)) { log.Error(ErrorHelper.AppendSlxErrorId("The call to CopySelectedUsers() failed", sSlxErrorId), exp); } DialogService.ShowHtmlMessage(sMsg, GetLocalResourceObject("ErrorMessageTitle").ToString(), ErrorHelper.IsDevelopmentContext() ? 600 : -1, ErrorHelper.IsDevelopmentContext() ? 800 : -1); } }
private AddUserOptions GetOptions() { AddUserOptions options = new AddUserOptions(); UserTypeInfo info = UserTypeInfo.GetTypeInfoFromCode(lbxUserType.SelectedValue); options.UserType = info.UserType; if (String.IsNullOrEmpty(ddlQuantity.SelectedValue)) { options.Quantity = 1; } else { options.Quantity = System.Convert.ToInt32(ddlQuantity.SelectedValue); } if (chkCreateFromProfile.Checked) { options.CreateFromProfile = true; if (rdoProfileFrom.SelectedValue == "U") { if (string.IsNullOrEmpty(lueAddUser.LookupResultValue.ToString())) { throw new ValidationException(GetLocalResourceObject("lueAddUser.Validate").ToString()); } options.TemplateID = lueAddUser.LookupResultValue.ToString(); } else { options.TemplateID = lbxTemplates.SelectedValue; } } else { options.CreateFromProfile = false; options.TemplateID = string.Empty; } options.UseGeneralProfile = chkGeneral.Checked; options.UseEmployeeProfile = chkEmployee.Checked; options.UseCalendarProfile = chkCalender.Checked; options.UseClientOptionsProfile = chkClientOptions.Checked; options.UseSecurityProfile = chkSecurity.Checked; options.UseSupportProfile = chkServiceAndSupport.Checked; options.UseTeamsProfile = chkTeams.Checked; return options; }