Esempio n. 1
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                LdapService  = ScopedServices.GetRequiredService <ILdapService>();
                GroupService = ScopedServices.GetRequiredService <IGroupService>();

                LdapSettings = await AppSettingsService.GetLdapSettingsAsync();

                if (LdapSettings == null)
                {
                    ActiveDirectoryInitialization = ActiveDirectoryInitialization.HostNotSet;
                }
                else if (LdapSettings?.Host != null && LdapSettings?.UserName == null && LdapSettings?.Password == null)
                {
                    ActiveDirectoryInitialization = ActiveDirectoryInitialization.CredentialsNotSet;
                }
                else
                {
                    await GetGroups(LdapSettings);
                }

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CancelAsync();
            }
        }
Esempio n. 2
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                EmployeeService = ScopedServices.GetRequiredService <IEmployeeService>();
                LdapService     = ScopedServices.GetRequiredService <ILdapService>();
                RemoteDeviceConnectionsService = ScopedServices.GetRequiredService <IRemoteDeviceConnectionsService>();

                Account = await EmployeeService.GetAccountByIdAsync(AccountId);

                if (Account == null)
                {
                    throw new HESException(HESCode.AccountNotFound);
                }

                EntityBeingEdited = MemoryCache.TryGetValue(Account.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(Account.Id, Account);
                }

                Employee = await EmployeeService.GetEmployeeByIdAsync(Account.EmployeeId);

                LdapSettings = await AppSettingsService.GetLdapSettingsAsync();

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
Esempio n. 3
0
        private async Task LoadLdapSettingsAsync()
        {
            var ldapSettings = await AppSettingsService.GetLdapSettingsAsync();

            if (ldapSettings?.Password != null)
            {
                LdapHost = ldapSettings.Host.Split(".")[0];
            }
        }
        private async Task AddVaultAsync()
        {
            try
            {
                if (SelectedHardwareVault == null)
                {
                    WarningMessage = "Please, select a vault.";
                    return;
                }

                using (TransactionScope transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
                {
                    await EmployeeService.AddHardwareVaultAsync(EmployeeId, SelectedHardwareVault.Id);

                    var ldapSettings = await AppSettingsService.GetLdapSettingsAsync();

                    if (ldapSettings?.Password != null)
                    {
                        var employee = await EmployeeService.GetEmployeeByIdAsync(EmployeeId);

                        if (employee.ActiveDirectoryGuid != null)
                        {
                            await LdapService.AddUserToHideezKeyOwnersAsync(ldapSettings, employee.ActiveDirectoryGuid);
                        }
                    }

                    transactionScope.Complete();
                }

                await Refresh.InvokeAsync(this);

                await ToastService.ShowToastAsync("Vault added", ToastType.Success);

                await SynchronizationService.UpdateEmployeeDetails(ExceptPageId, EmployeeId);

                await SynchronizationService.HardwareVaultStateChanged(SelectedHardwareVault.Id);

                await ModalDialogService.CloseAsync();
            }
            catch (Exception ex)
            {
                await ModalDialogService.CloseAsync();

                Logger.LogError(ex.Message, ex);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
            }
        }
        private async Task DeleteAsync()
        {
            try
            {
                var ldapSettings = await AppSettingsService.GetLdapSettingsAsync();

                ldapSettings.UserName = null;
                ldapSettings.Password = null;
                await AppSettingsService.SetLdapSettingsAsync(ldapSettings);

                await ToastService.ShowToastAsync("Domain settings updated.", ToastType.Success);
                await ModalDialogClose();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message, ex);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
Esempio n. 6
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                LdapService = ScopedServices.GetRequiredService<ILdapService>();

                LdapSettings = await AppSettingsService.GetLdapSettingsAsync();

                if (LdapSettings?.UserName == null && LdapSettings?.Password == null)
                {
                    CredentialsNotSet = true;
                }

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
Esempio n. 7
0
        protected override async Task OnInitializedAsync()
        {
            var setting = await AppSettingsService.GetLdapSettingsAsync();

            if (setting == null)
            {
                LdapSettings = new LdapSettings()
                {
                    Host = Host
                }
            }
            ;
            else
            {
                LdapSettings = new LdapSettings()
                {
                    Host           = Host,
                    MaxPasswordAge = setting.MaxPasswordAge
                }
            };

            LdapSettingsContext = new EditContext(LdapSettings);
        }
Esempio n. 8
0
        private async Task <string> LoadDomainSettingsAsync()
        {
            var domainSettings = await AppSettingsService.GetLdapSettingsAsync();

            return(domainSettings?.Host);
        }