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

sources/ldap: include UnwillingToPerformError as possible exception #6031

Merged
merged 1 commit into from Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -166,6 +166,7 @@ dmypy.json
# SageMath parsed files

# Environments
**/.DS_Store

# Spyder project settings

Expand Down
6 changes: 3 additions & 3 deletions authentik/sources/ldap/password.py
Expand Up @@ -4,7 +4,7 @@
from typing import Optional

from ldap3 import BASE
from ldap3.core.exceptions import LDAPAttributeError
from ldap3.core.exceptions import LDAPAttributeError, LDAPUnwillingToPerformResult
from structlog.stdlib import get_logger

from authentik.core.models import User
Expand Down Expand Up @@ -69,7 +69,7 @@
attributes=["pwdProperties"],
)
root_attrs = list(root_attrs)[0]
except (LDAPAttributeError, KeyError, IndexError):
except (LDAPAttributeError, LDAPUnwillingToPerformResult, KeyError, IndexError):

Check warning on line 72 in authentik/sources/ldap/password.py

View check run for this annotation

Codecov / codecov/patch

authentik/sources/ldap/password.py#L72

Added line #L72 was not covered by tests
return False
raw_pwd_properties = root_attrs.get("attributes", {}).get("pwdProperties", None)
if not raw_pwd_properties:
Expand All @@ -92,7 +92,7 @@
return
try:
self._connection.extend.microsoft.modify_password(user_dn, password)
except LDAPAttributeError:
except (LDAPAttributeError, LDAPUnwillingToPerformResult):

Check warning on line 95 in authentik/sources/ldap/password.py

View check run for this annotation

Codecov / codecov/patch

authentik/sources/ldap/password.py#L95

Added line #L95 was not covered by tests
self._connection.extend.standard.modify_password(user_dn, new_password=password)

def _ad_check_password_existing(self, password: str, user_dn: str) -> bool:
Expand Down