Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win_domain_user: Fix issue when trying to update user password when u… #289

Merged

Conversation

dev-ddoe
Copy link
Contributor

@dev-ddoe dev-ddoe commented Aug 26, 2021

win_domain_user: Use SAM when user have no upn during password verification

SUMMARY

On AD, explicit upn is not mandatory.

When the following playbook is played

    name: bob
    firstname: Bob
    surname: Smith
    password: B0bP4ssw0rd
    update_password: when_changed
    state: present
    domain_username: DOMAIN\admin-account
    domain_password: SomePas2w0rd
    domain_server: [email protected]

it works properly the first time but when it is played a second time,
it fails because password verification is done using upn of the user.
But user does not have a upn

The error returned is

An exception occurred during task execution. To see the full traceback, use -vvv. The error was:    at CallSite.Target(Closure , CallSite , Type , String , String , String , String , String )
fatal: [ad1]: FAILED! => {"changed": false, "msg": "Unhandled exception while executing module: Failed to logon  (The parameter is incorrect, Win32ErrorCode 87 - 0x00000057)"}
WORKAROUND

using

update_password: always

prevents password verification

@jborean93
Copy link
Collaborator

Is there a way to get the NETBIOS domain part from the AD user object? My only concern with this is if the sAMAccountName is also the same name as a local user on the host in question. Being able to do DOMAIN\username as the fallback if the UPN is not present should solve that problem.

@dev-ddoe
Copy link
Contributor Author

Good point.
I've updated the PR in order to get the constructed attribute msDS-PrincipalName which contain the username in the form:
DOMAIN\user

Copy link
Collaborator

@jborean93 jborean93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, I pushed a slight change which added the changelog fragment and a tweak so that Test-Credential is only called in 1 place rather than be doubled up.

@jborean93 jborean93 merged commit 05cf589 into ansible-collections:main Sep 23, 2021
@dev-ddoe dev-ddoe deleted the fix/password_verif_no_upn branch September 23, 2021 07:35
@dev-ddoe
Copy link
Contributor Author

It looks good. thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants