private async Task <IEnumerable <String> > ImportUserAsync(APIOptions apiOptions, IGenericRepository <kCura.Relativity.Client.DTOs.User> userRepository) { List <String> violations = new List <string>(); kCura.Relativity.Client.DTOs.User user = null; try { apiOptions.WorkspaceID = -1; user = new kCura.Relativity.Client.DTOs.User() { FirstName = (String)await FirstName.GetDataValueAsync(), LastName = (String)await LastName.GetDataValueAsync(), EmailAddress = (String)await EmailAddress.GetDataValueAsync(), Groups = _groupList, Type = _userType, Client = _client, RelativityAccess = ((Boolean?)await RelativityAccess.GetDataValueAsync()).GetValueOrDefault(), DocumentSkip = _documentSkip, BetaUser = ((Boolean?)await BetaUser.GetDataValueAsync()).GetValueOrDefault(), ChangeSettings = ((Boolean?)await ChangeSettings.GetDataValueAsync()).GetValueOrDefault(), KeyboardShortcuts = ((Boolean?)await KeyboardShortcuts.GetDataValueAsync()).GetValueOrDefault(), ItemListPageLength = ((Int32?)await ItemListPageLength.GetDataValueAsync()).GetValueOrDefault(), DefaultSelectedFileType = _defaultSelectedFileType, SkipDefaultPreference = _skipDefaultPreference, EnforceViewerCompatibility = ((Boolean?)await EnforceViewerCompatibility.GetDataValueAsync()).GetValueOrDefault(), AdvancedSearchPublicByDefault = ((Boolean?)await AdvancedSearchPublicByDefault.GetDataValueAsync()).GetValueOrDefault(), NativeViewerCacheAhead = ((Boolean?)await NativeViewerCacheAhead.GetDataValueAsync()).GetValueOrDefault(), CanChangeDocumentViewer = ((Boolean?)await ChangeDocumentViewer.GetDataValueAsync()).GetValueOrDefault(), DocumentViewer = _documentViewer, TrustedIPs = String.Empty, ChangePassword = ((Boolean?)await CanChangePassword.GetDataValueAsync()).GetValueOrDefault(), MaximumPasswordAge = ((Int32?)await MaximumPasswordAgeInDays.GetDataValueAsync()).GetValueOrDefault(), DataFocus = 1, // This field is no longer utilized in Relativity, however it's hardcoded because it is required ChangePasswordNextLogin = ((Boolean?)await UserMustChangePasswordOnNextLogin.GetDataValueAsync()).GetValueOrDefault() }; ArtifactId = userRepository.CreateSingle(user); } catch (Exception ex) { String msg = null; if (ex.ToString().Contains("The entered E-Mail Address is already associated with a user") && user != null && !String.IsNullOrWhiteSpace(user.EmailAddress)) { msg = String.Format(Constant.ErrorMessages.UserAlreadyExists, user.EmailAddress); } else { msg = ex.ToString(); } violations.Add(msg); } return(violations); }
private async Task <IEnumerable <String> > ImportLoginMethodAsync(IHelper helper) { List <String> violations = new List <string>(); try { using (var loginManager = helper.GetServicesManager().CreateProxy <ILoginProfileManager>(ExecutionIdentity.CurrentUser)) { var userLoginProfile = await loginManager.GetLoginProfileAsync(ArtifactId); if (!String.IsNullOrWhiteSpace(TwoFactorMode.Data) && !String.IsNullOrWhiteSpace(TwoFactorInfo.Data)) { userLoginProfile.Password = new PasswordMethod() { IsEnabled = true, MustResetPasswordOnNextLogin = ((Boolean?)(await UserMustChangePasswordOnNextLogin.GetDataValueAsync())).GetValueOrDefault(), UserCanChangePassword = ((Boolean?)(await CanChangePassword.GetDataValueAsync())).GetValueOrDefault(), PasswordExpirationInDays = ((Int32?)(await MaximumPasswordAgeInDays.GetDataValueAsync())).GetValueOrDefault(), TwoFactorMode = (TwoFactorMode)Enum.Parse(typeof(TwoFactorMode), (String)(await TwoFactorMode.GetDataValueAsync())), TwoFactorInfo = ((String)(await TwoFactorInfo.GetDataValueAsync())) }; } if (!String.IsNullOrWhiteSpace(WindowsAccount.Data)) { userLoginProfile.IntegratedAuthentication = new IntegratedAuthenticationMethod() { IsEnabled = true, Account = (String)(await WindowsAccount.GetDataValueAsync()) }; } await loginManager.SaveLoginProfileAsync(userLoginProfile); } } catch (Exception ex) { violations.Add(ex.ToString()); } return(violations); }