Пример #1
0
        void CallPasswordScript(PasswordOperation Action, CSEntry csentry, SecureString oldPassword, SecureString newPassword, PasswordOptions options)
        {
            Tracer.Enter("callpasswordscript");
            PSDataCollection <PSObject> passwordPipeline = new PSDataCollection <PSObject>();

            try
            {
                Command cmd = new Command(Path.GetFullPath(PasswordManagementScript));
                cmd.Parameters.Add(new CommandParameter("Username", Username));
                cmd.Parameters.Add(new CommandParameter("Password", Password));
                cmd.Parameters.Add(new CommandParameter("Credentials", GetSecureCredentials(Username, SecureStringPassword)));

                cmd.Parameters.Add(new CommandParameter("AuxUsernameAux", UsernameAux));
                cmd.Parameters.Add(new CommandParameter("AuxPasswordAux", PasswordAux));
                cmd.Parameters.Add(new CommandParameter("AuxCredentialsAux", GetSecureCredentials(UsernameAux, SecureStringPasswordAux)));

                cmd.Parameters.Add(new CommandParameter("ConfigurationParameter", ConfigurationParameter));

                cmd.Parameters.Add(new CommandParameter("Action", Action.ToString()));

                if (options.HasFlag(PasswordOptions.UnlockAccount))
                {
                    cmd.Parameters.Add(new CommandParameter("UnlockAccount"));
                }
                if (options.HasFlag(PasswordOptions.ForceChangeAtLogOn))
                {
                    cmd.Parameters.Add(new CommandParameter("ForceChangeAtLogOn"));
                }
                if (options.HasFlag(PasswordOptions.ValidatePassword))
                {
                    cmd.Parameters.Add(new CommandParameter("ValidatePassword"));
                }
                cmd.Parameters.Add(new CommandParameter("NewPassword", newPassword.ConvertToUnsecureString()));
                if (Action == PasswordOperation.Change)
                {
                    cmd.Parameters.Add(new CommandParameter("OldPassword", oldPassword.ConvertToUnsecureString()));
                }
                passwordPipeline.Add(new PSObject(csentry));
                passwordResults = InvokePowerShellScript(cmd, passwordPipeline);
            }
            catch (Exception ex)
            {
                Tracer.TraceError("callpasswordscript", ex);
                throw;
            }
            finally
            {
                passwordPipeline = null;
                Tracer.TraceInformation("callpasswordscript");
            }
        }
Пример #2
0
 private PasswordService(PasswordOptions options)
 {
     exclusionSet  = " `~^*()_-{}[];:'\"<>,./|\\";
     Minimum       = DefaultMinimum;
     Maximum       = DefaultMaximum;
     noConsecutive = options.HasFlag(PasswordOptions.NoConsecutive);
     noRepeating   = options.HasFlag(PasswordOptions.NoRepeating);
     hasSymbols    = options.HasFlag(PasswordOptions.HasSymbols);
     hasDigits     = options.HasFlag(PasswordOptions.HasDigits);
     hasCapitals   = options.HasFlag(PasswordOptions.HasCapitals);
     hasLower      = options.HasFlag(PasswordOptions.HasLower);
     rng           = new RNGCryptoServiceProvider();
 }