Exemplo n.º 1
0
        internal LocalUserInfoUpdate(Model.LocalUserInfo user, IUserShell shell)
        {
            _shell = shell;
            _user  = user;

            _cache = new ConfigurationCache();
        }
Exemplo n.º 2
0
        public ILocalUserInfoUpdate RollbackOnError()
        {
            _cache.RollbackOnError = true;

            if (_cache.RollbackOnError.GetValueOrDefault())
            {
                var service = _shell.GetLocalUser(_user.Name);

                _backupConfig = CreateBackupConfig(service, _cache);
            }

            return(this);
        }
Exemplo n.º 3
0
        private void Update(ConfigurationCache config)
        {
            if (config.AccountDisabled.HasValue)
            {
                _shell.SetAccountDisabled(_user.Name, config.AccountDisabled.Value);
            }

            if (config.Password != null)
            {
                _shell.ChangePassword(_user.Name, config.Password);
            }

            if (config.IsVisible.HasValue)
            {
                _shell.SetUserVisibility(_user.Name, config.IsVisible.Value);
            }

            if (config.PasswordCanBeChangedByUser.HasValue)
            {
                _shell.SetPasswordCanBeChangedByUser(_user.Name, config.PasswordCanBeChangedByUser.Value);
            }

            if (config.PasswordRequired.HasValue)
            {
                _shell.SetPasswordRequired(_user.Name, config.PasswordRequired.Value);
            }

            if (config.PasswordCanExpire.HasValue)
            {
                _shell.SetPasswordCanExpire(_user.Name, config.PasswordCanExpire.Value);
            }

            if (config.PasswordExpired.HasValue)
            {
                _shell.SetPasswordExpired(_user.Name, config.PasswordExpired.Value);
            }

            if (config.Desription != null)
            {
                _shell.SetUserDescription(_user.Name, config.Desription);
            }

            if (config.FullName != null)
            {
                _shell.SetUserFullName(_user.Name, config.FullName);
            }
        }
Exemplo n.º 4
0
        private ConfigurationCache CreateBackupConfig(Model.LocalUserInfo actualUser, ConfigurationCache cache)
        {
            var rollback = new ConfigurationCache();

            if (cache.AccountDisabled.HasValue)
            {
                rollback.AccountDisabled = actualUser.AccountDisabled;
            }

            if (cache.IsVisible.HasValue)
            {
                rollback.IsVisible = actualUser.IsVisible;
            }

            if (cache.PasswordCanBeChangedByUser.HasValue)
            {
                rollback.PasswordCanBeChangedByUser = actualUser.PasswordCanBeChangedByUser;
            }

            if (cache.PasswordRequired.HasValue)
            {
                rollback.PasswordRequired = actualUser.PasswordRequired;
            }

            if (cache.PasswordCanExpire.HasValue)
            {
                rollback.PasswordCanExpire = actualUser.PasswordExpires.HasValue;
            }

            if (cache.PasswordExpired.HasValue)
            {
                rollback.PasswordExpired = actualUser.PasswordExpires.HasValue &&
                                           actualUser.PasswordExpires.Value.Date > DateTime.Now;
            }

            if (cache.Desription != null)
            {
                rollback.Desription = actualUser.Description;
            }

            return(rollback);
        }