Skip to content

Commit

Permalink
fix: improve error messaging for Windows logon (#219)
Browse files Browse the repository at this point in the history
Summary:

The current code structure for logging on and loading the user profile
blurs the line between password-related logon failures, and agent-user
permission-related logon failures.

Solution:

Break-up the code that's in a single try-catch to split it into multiple
try-catches.

Signed-off-by: Daniel Neilson <53624638+ddneilson@users.noreply.github.com>
  • Loading branch information
ddneilson authored Mar 18, 2024
1 parent 1d97970 commit de23226
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions src/deadline_worker_agent/windows/win_credentials_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,21 +219,36 @@ def get_windows_session_user(self, user: str, passwordArn: str) -> WindowsSessio
Password=password,
Domain=None,
)
# https://timgolden.me.uk/pywin32-docs/win32profile__LoadUserProfile_meth.html
user_profile = LoadUserProfile(
logon_token,
{
"UserName": user,
"Flags": PI_NOUI,
"ProfilePath": None,
},
)
windows_session_user = WindowsSessionUser(
user=user,
logon_token=cHANDLE(int(logon_token)),
)
except OSError as e:
logger.error(f'Error logging on as "{user}": {e}')
logger.error(
f'Error logging on as "{user}", please check that your password within {passwordArn} is correct: {e}'
)
else:
try:
# https://timgolden.me.uk/pywin32-docs/win32profile__LoadUserProfile_meth.html
user_profile = LoadUserProfile(
logon_token,
{
"UserName": user,
"Flags": PI_NOUI,
"ProfilePath": None,
},
)
except OSError as e:
logger.error(
(
f'Error loading profile for "{user}": {e}\n'
"Please ensure that the Worker Agent is running as a user that is an Administrator, and has user rights to both backup and restore files and directories."
)
)
else:
try:
windows_session_user = WindowsSessionUser(
user=user,
logon_token=cHANDLE(int(logon_token)),
)
except OSError as e:
logger.error(f'Error logging on as "{user}": {e}')
else:
try:
# OpenJD will test the ultimate validity of the credentials when creating a WindowsSessionUser
Expand Down

0 comments on commit de23226

Please sign in to comment.