Skip to content

Commit

Permalink
feat: include UnwillingToPerformError as possible exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Samir Musali committed Jun 21, 2023
1 parent 17fbba2 commit c807679
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
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 @@ def check_ad_password_complexity_enabled(self) -> bool:
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 @@ def change_password(self, user: User, password: str):
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

0 comments on commit c807679

Please sign in to comment.