Skip to content

Commit

Permalink
fix: create login properly when skip reset set (#287)
Browse files Browse the repository at this point in the history
* fix: create login properly when skip reset set

* chore: add release info

* fix: new login still needs pwd
  • Loading branch information
lowlydba authored Dec 8, 2024
1 parent 24552a7 commit 4b17fda
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ lowlydba.sqlserver Release Notes

.. contents:: Topics

v2.3.5
======

Release Summary
---------------

Bugfix for login module when creating new logins.

Bugfixes
--------

- Fix error that occurred when creating a login with `skip_password_reset` as true. (https://github.com/lowlydba/lowlydba.sqlserver/pull/287)

v2.3.4
======

Expand Down
9 changes: 9 additions & 0 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -514,3 +514,12 @@ releases:
fragments:
- 266-restore-warnings.yaml
release_date: '2024-10-06'
2.3.5:
changes:
bugfixes:
- Fix error that occurred when creating a login with `skip_password_reset` as
true. (https://github.com/lowlydba/lowlydba.sqlserver/pull/287)
release_summary: Bugfix for login module when creating new logins.
fragments:
- 287-login-bugfix.yml
release_date: '2024-12-08'
11 changes: 6 additions & 5 deletions plugins/modules/login.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@ try {
$setLoginSplat.add("PasswordMustChange", $true)
}
}
if (($null -ne $secPassword) -and ($skip_password_reset -eq $false)) {
$setLoginSplat.add("SecurePassword", $secPassword)
$changed = $true
}

# Login already exists
if ($null -ne $existingLogin) {
if (($null -ne $secPassword) -and ($skip_password_reset -eq $false)) {
$setLoginSplat.add("SecurePassword", $secPassword)
$changed = $true
}

# Splat login status
if ($enabled -eq $false) {
$disabled = $true
Expand All @@ -122,6 +123,7 @@ try {
}
# New login
else {
$setLoginSplat.add("SecurePassword", $secPassword)
if ($null -ne $language) {
$setLoginSplat.add("Language", $language)
}
Expand All @@ -139,7 +141,6 @@ try {
$output.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("DefaultDatabase")
$output.PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames.Add("Language")
}

}

if ($null -ne $output) {
Expand Down
1 change: 1 addition & 0 deletions tests/integration/targets/login/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- name: Create login
lowlydba.sqlserver.login:
password_policy_enforced: "{{ password_policy_enforced }}"
skip_password_reset: true
register: result
- assert:
that:
Expand Down

0 comments on commit 4b17fda

Please sign in to comment.