Skip to content

Commit a0fe677

Browse files
authored
sources/ldap: make server info optional (#18648)
Signed-off-by: Jens Langhammer <[email protected]>
1 parent 3548d5e commit a0fe677

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

authentik/sources/ldap/models.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,16 @@ def sync_lock(self) -> pglock.advisory:
298298
side_effect=pglock.Return,
299299
)
300300

301+
def get_ldap_server_info(self, srv: Server) -> dict[str, str]:
302+
info = {
303+
"vendor": _("N/A"),
304+
"version": _("N/A"),
305+
}
306+
if srv.info:
307+
info["vendor"] = str(flatten(srv.info.vendor_name))
308+
info["version"] = str(flatten(srv.info.vendor_version))
309+
return info
310+
301311
def check_connection(self) -> dict[str, dict[str, str]]:
302312
"""Check LDAP Connection"""
303313
servers = self.server()
@@ -308,9 +318,8 @@ def check_connection(self) -> dict[str, dict[str, str]]:
308318
try:
309319
conn = self.connection(server=server)
310320
server_info[server.host] = {
311-
"vendor": str(flatten(conn.server.info.vendor_name)),
312-
"version": str(flatten(conn.server.info.vendor_version)),
313321
"status": "ok",
322+
**self.get_ldap_server_info(conn.server),
314323
}
315324
except LDAPException as exc:
316325
server_info[server.host] = {
@@ -320,9 +329,8 @@ def check_connection(self) -> dict[str, dict[str, str]]:
320329
try:
321330
conn = self.connection()
322331
server_info["__all__"] = {
323-
"vendor": str(flatten(conn.server.info.vendor_name)),
324-
"version": str(flatten(conn.server.info.vendor_version)),
325332
"status": "ok",
333+
**self.get_ldap_server_info(conn.server),
326334
}
327335
except LDAPException as exc:
328336
server_info["__all__"] = {

0 commit comments

Comments
 (0)