public async Task <PasswordTestResult> TestPassword(string username, string password) { try { UserPrincipal up = await WindowsSamController.GetUserPrincipal(username); PasswordTestResultCode result = (PasswordTestResultCode)(int)FilterInterface.TestPassword(up.SamAccountName, up.DisplayName, password, false); if (result != PasswordTestResultCode.Approved) { Logger.Warn($"User {username} attempted to set a password that was rejected by Lithnet Password Protection with the following code: {result}"); } return(new PasswordTestResult(result)); } catch (NotFoundException) { throw; } catch (Exception ex) { Logger.Error(ex, "An unexpected error occurred checking the password against the Lithnet Password Protection service"); if (PasswordChangeConfigSection.Configuration.PasswordTesting.LppIgnoreErrors) { return(new PasswordTestResult()); } else { return(new PasswordTestResult(PasswordTestResultCode.GeneralError)); } } }
protected override void ProcessRecord() { this.WriteObject(FilterInterface.TestPassword(this.Username, this.Fullname, this.ParameterSetName == "String" ? this.Password : this.SecurePassword.SecureStringToString(), this.IsSetOperation)); }