diff --git a/src/sambal/client.py b/src/sambal/client.py index 5663d6f..63e763f 100644 --- a/src/sambal/client.py +++ b/src/sambal/client.py @@ -1,5 +1,6 @@ from typing import Optional +from ldb import LdbError from samba.auth import system_session from samba.credentials import Credentials from samba.param import LoadParm @@ -24,12 +25,15 @@ def connect_samdb(username, password, host, realm=None) -> Optional[SamDB]: if realm: creds.set_realm(realm) - return SamDB( - url=url, - session_info=system_session(), - credentials=creds, - lp=lp, - ) + try: + return SamDB( + url=url, + session_info=system_session(), + credentials=creds, + lp=lp, + ) + except LdbError: + return None def get_samdb(request) -> Optional[SamDB]: diff --git a/src/sambal/templates/login.jinja2 b/src/sambal/templates/login.jinja2 index 6772332..4b1139a 100644 --- a/src/sambal/templates/login.jinja2 +++ b/src/sambal/templates/login.jinja2 @@ -13,6 +13,15 @@