From 893e372c8f4bea5c490be2b784f16bde70f0b8d0 Mon Sep 17 00:00:00 2001 From: Ajit Awekar Date: Mon, 23 Nov 2026 18:13:49 +0530 Subject: [PATCH v4 5/5] Add LDAP account-existence check to credential validation Register a CVT_LDAP validator for LDAP sessions. An LDAP session keeps no credential with an expiry of its own, because the password is used for the bind and then discarded, so the check re-runs the configured search filter and ends the session once the account is no longer found. A failed check records the user and the reason for the server log. Only search+bind mode can be re-checked; a simple-bind session keeps no credentials to search with and is treated as valid. So is any failure to reach or search the directory, so that an outage does not end established sessions. The settings needed are copied out of the HbaLine at authentication, which is freed early in backend startup. The check blocks the backend while it talks to the directory, so connecting, binding and searching are each limited to credential_validation_ldap_timeout seconds (default 5, not applied on Windows); a timeout is treated like any other LDAP error. Tests: ldap/t/004_ldap_continuous_validation.pl deletes the account of an open session and checks that the session is terminated. --- doc/src/sgml/config.sgml | 47 +++- src/backend/libpq/auth-validate-methods.c | 33 +++ src/backend/libpq/auth-validate.c | 2 + src/backend/libpq/auth.c | 231 ++++++++++++++++++ src/backend/utils/misc/guc_parameters.dat | 10 + src/backend/utils/misc/postgresql.conf.sample | 1 + src/include/libpq/auth-validate.h | 1 + src/include/libpq/auth.h | 10 + src/test/ldap/meson.build | 1 + .../ldap/t/004_ldap_continuous_validation.pl | 146 +++++++++++ 10 files changed, 481 insertions(+), 1 deletion(-) create mode 100644 src/test/ldap/t/004_ldap_continuous_validation.pl diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 17ab48c20b4..7ba950edc69 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -1140,7 +1140,8 @@ include_dir 'conf.d' depending on the authentication method, an additional method-specific check is applied, such as expiration of an OAuth bearer token, of the client certificate, or of the - GSSAPI security context. The default is + GSSAPI security context, or the disappearance of + an LDAP account. The default is off. @@ -1174,6 +1175,25 @@ include_dir 'conf.d' on Windows, and sessions that use SSPI are not covered by the GSSAPI checks. + + For LDAP sessions, the check repeats the search + that was used at authentication, with the configured search filter, + and terminates the session if the account is no longer found. This + only applies to the search+bind mode (ldapbasedn + is set); a session authenticated with simple bind, which keeps no + credentials to search with, is always treated as valid. A failure to + reach or search the directory is also treated as valid, so that a + temporary directory outage does not end established sessions. The + check contacts the LDAP server every time it runs, + so a longer is + advisable for these sessions. The session cannot process other + input while the check waits for the directory, so connecting, binding + and searching are each limited to + ; a timeout is + treated like any other failure to reach the directory. This limit is + not applied on Windows, where the LDAP client + library's own timeouts apply. + The re-validation period is controlled by . Validation is @@ -1227,6 +1247,31 @@ include_dir 'conf.d' + + credential_validation_ldap_timeout (integer) + + credential_validation_ldap_timeout configuration parameter + + + + + + Sets how long, for LDAP sessions, a credential + re-validation waits on the directory server. The limit applies + separately to connecting, binding and searching, so one check can take + up to three times this value. If a step times out, the check is + treated like any other failure to reach the directory and the session + is left open. If this value is specified without units, it is taken + as seconds. The valid range is from 1 second to 60 seconds, and the + default is 5 seconds. It has no effect on Windows. + + + Like , this + parameter can only be set at session start and cannot be changed + within a session. + + + credential_validation_kdc_timeout (integer) diff --git a/src/backend/libpq/auth-validate-methods.c b/src/backend/libpq/auth-validate-methods.c index fb09c29d0f6..0df57f6e841 100644 --- a/src/backend/libpq/auth-validate-methods.c +++ b/src/backend/libpq/auth-validate-methods.c @@ -32,6 +32,7 @@ static bool validate_oauth_credentials(void); static bool validate_cert_credentials(void); static bool validate_gss_credentials(void); +static bool validate_ldap_credentials(void); /* * Initialize validation methods @@ -46,6 +47,7 @@ InitializeValidationMethods(void) RegisterCredentialValidator(CVT_OAUTH, validate_oauth_credentials); RegisterCredentialValidator(CVT_CERT, validate_cert_credentials); RegisterCredentialValidator(CVT_GSS, validate_gss_credentials); + RegisterCredentialValidator(CVT_LDAP, validate_ldap_credentials); } /* @@ -194,3 +196,34 @@ validate_gss_credentials(void) return true; } + +/* + * CVT_LDAP validator: an LDAP session keeps no credential with an expiry of + * its own, because the password is used for the bind and then discarded. What + * can be re-checked is whether the account still exists in the directory and + * still satisfies the configured search filter. CheckLDAPCredentialValidity() + * re-runs that search; see the comment there for its scope and limits. + * + * Note that this makes a round trip to the LDAP server on every validation + * cycle, so a larger credential_validation_interval is advisable for LDAP + * sessions. + */ +static bool +validate_ldap_credentials(void) +{ +#ifdef USE_LDAP + Port *port = MyProcPort; + + if (port == NULL) + return true; + + if (!CheckLDAPCredentialValidity(port)) + { + SetCredentialValidationFailureDetail("LDAP check failed for user \"%s\": account no longer exists in the directory", + port->user_name); + return false; + } +#endif + + return true; +} diff --git a/src/backend/libpq/auth-validate.c b/src/backend/libpq/auth-validate.c index f39f7e918d1..123453d9d9c 100644 --- a/src/backend/libpq/auth-validate.c +++ b/src/backend/libpq/auth-validate.c @@ -76,6 +76,8 @@ UserAuthToValidationType(UserAuth auth_method) return CVT_CERT; case uaGSS: return CVT_GSS; + case uaLDAP: + return CVT_LDAP; default: /* diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c index 16cf3c93067..f031abba154 100644 --- a/src/backend/libpq/auth.c +++ b/src/backend/libpq/auth.c @@ -148,6 +148,7 @@ static int CheckBSDAuth(Port *port, char *user); #endif static int CheckLDAPAuth(Port *port); +static void save_ldap_validation_params(Port *port); /* LDAP_OPT_DIAGNOSTIC_MESSAGE is the newer spelling */ #ifndef LDAP_OPT_DIAGNOSTIC_MESSAGE @@ -158,6 +159,31 @@ static int CheckLDAPAuth(Port *port); static char *dummy_ldap_password_mutator(char *input); auth_password_hook_typ ldap_password_hook = dummy_ldap_password_mutator; +/* + * Session-lifetime snapshot of the pg_hba LDAP settings, taken at + * authentication time and used later by CheckLDAPCredentialValidity(). The + * HbaLine that port->hba points at lives in PostmasterContext, which is + * destroyed before the backend enters its main command loop, so the settings + * needed to re-validate the session must be copied somewhere longer-lived. + */ +static HbaLine *ldap_validation_hba = NULL; + +/* + * Credential validation waits at most credential_validation_ldap_timeout + * seconds on the directory server for each of connecting, binding and + * searching. Validation runs inside an otherwise idle session and must not + * stall it for the LDAP library's much longer defaults; a timeout is treated + * like any other LDAP error (the session is left alone). Not applied on + * Windows, which has no equivalent option. + */ + +/* + * Set only while CheckLDAPCredentialValidity() calls + * InitializeLDAPConnection(), so that the connection it opens is bounded + * from the start, StartTLS included. Zero (the normal case) means no limit. + */ +static int ldap_connect_timeout_secs = 0; + #endif /* USE_LDAP */ /*---------------------------------------------------------------- @@ -176,6 +202,7 @@ static int CheckCertAuth(Port *port); char *pg_krb_server_keyfile; bool pg_krb_caseins_users; bool pg_gss_accept_delegation; +int credential_validation_ldap_timeout; int credential_validation_kdc_timeout; @@ -2567,6 +2594,31 @@ InitializeLDAPConnection(Port *port, LDAP **ldap) return STATUS_ERROR; } +#ifndef WIN32 + if (ldap_connect_timeout_secs > 0) + { + struct timeval tv; + + tv.tv_sec = ldap_connect_timeout_secs; + tv.tv_usec = 0; + + /* + * LDAP_OPT_NETWORK_TIMEOUT bounds connecting; LDAP_OPT_TIMEOUT the + * wait for each synchronous operation, such as the bind + */ + if ((r = ldap_set_option(*ldap, LDAP_OPT_NETWORK_TIMEOUT, &tv)) != LDAP_SUCCESS || + (r = ldap_set_option(*ldap, LDAP_OPT_TIMEOUT, &tv)) != LDAP_SUCCESS) + { + ereport(LOG, + (errmsg("could not set LDAP timeout: %s", + ldap_err2string(r)), + errdetail_for_ldap(*ldap))); + ldap_unbind(*ldap); + return STATUS_ERROR; + } + } +#endif + if (port->hba->ldaptls) { #ifndef WIN32 @@ -2850,6 +2902,12 @@ CheckLDAPAuth(Port *port) /* Save the original bind DN as the authenticated identity. */ set_authn_id(port, fulluser); + /* + * Snapshot the LDAP settings while port->hba is still valid, so that + * continuous credential validation can re-check the account later. + */ + save_ldap_validation_params(port); + ldap_unbind(ldap); pfree(passwd); pfree(fulluser); @@ -2857,6 +2915,179 @@ CheckLDAPAuth(Port *port) return STATUS_OK; } +/* + * Copy the LDAP-related pg_hba settings needed for credential re-validation + * into TopMemoryContext, where they survive for the life of the session. See + * the comment on ldap_validation_hba above for why this is necessary. + */ +static void +save_ldap_validation_params(Port *port) +{ + HbaLine *src = port->hba; + HbaLine *dst; + + dst = (HbaLine *) MemoryContextAllocZero(TopMemoryContext, sizeof(HbaLine)); + + dst->ldaptls = src->ldaptls; + dst->ldapport = src->ldapport; + dst->ldapscope = src->ldapscope; + +#define LDAP_SAVE_STR(field) \ + dst->field = src->field ? MemoryContextStrdup(TopMemoryContext, src->field) : NULL + + LDAP_SAVE_STR(ldapscheme); + LDAP_SAVE_STR(ldapserver); + LDAP_SAVE_STR(ldapbinddn); + LDAP_SAVE_STR(ldapbindpasswd); + LDAP_SAVE_STR(ldapsearchattribute); + LDAP_SAVE_STR(ldapsearchfilter); + LDAP_SAVE_STR(ldapbasedn); + +#undef LDAP_SAVE_STR + + ldap_validation_hba = dst; +} + +/* + * Re-validate an LDAP-authenticated session for continuous credential + * validation. + * + * An LDAP session keeps no credential with an intrinsic expiry (the user's + * password is discarded right after the bind), so "still valid" is defined + * here as: the user still exists in the directory and still satisfies the + * configured search filter. We re-bind with the configured search + * credentials (ldapbinddn / ldapbindpasswd) and re-run the same filter that + * was used at authentication time: + * + * - exactly one matching entry -> still valid + * - no matching entry -> the account has been deleted, moved out of + * the base DN, or no longer matches the + * filter (e.g. a filter that excludes + * disabled accounts) -> no longer valid + * + * This requires search+bind mode (ldapbasedn set): in simple-bind mode there + * are no retained credentials to bind with, so there is nothing to re-check + * and the session is treated as valid. Likewise, any operational failure + * (cannot connect, bind fails, search errors, ambiguous result) is treated + * conservatively as "still valid", so that a transient directory or network + * problem does not tear down established sessions; only a definitive "user is + * gone" result (zero entries) terminates the session. + * + * Returns true if the session should be considered still valid, false if the + * LDAP account is gone. + */ +bool +CheckLDAPCredentialValidity(Port *port) +{ + HbaLine *hba = ldap_validation_hba; + Port vport; + LDAP *ldap; + int r; + char *filter; + LDAPMessage *search_message = NULL; + char *attributes[] = {LDAP_NO_ATTRS, NULL}; + int count; + char *c; + + /* + * Only search+bind mode can be re-validated; simple bind (ldapprefix / + * ldapsuffix) retains no credentials with which to query the directory. A + * missing snapshot means this is not a search+bind LDAP session. + */ + if (hba == NULL || hba->ldapbasedn == NULL) + return true; + + /* + * As in CheckLDAPAuth, refuse user names that could inject filter syntax. + * Such a name could not have authenticated in the first place, so just + * treat it as still valid rather than risk a malformed search. + */ + for (c = port->user_name; *c; c++) + { + if (*c == '*' || *c == '(' || *c == ')' || *c == '\\' || *c == '/') + return true; + } + + /* + * InitializeLDAPConnection() reads its settings from port->hba, but the + * real port->hba has been freed by now (see ldap_validation_hba). Point + * a throwaway Port at our session-lifetime snapshot instead. + */ + vport = *port; + vport.hba = hba; + + ldap_connect_timeout_secs = credential_validation_ldap_timeout; + r = InitializeLDAPConnection(&vport, &ldap); + ldap_connect_timeout_secs = 0; + if (r == STATUS_ERROR) + return true; /* error already logged; fail open */ + + /* Bind with the search credentials (anonymous if none configured). */ + r = ldap_simple_bind_s(ldap, + hba->ldapbinddn ? hba->ldapbinddn : "", + hba->ldapbindpasswd ? ldap_password_hook(hba->ldapbindpasswd) : ""); + if (r != LDAP_SUCCESS) + { + ereport(LOG, + (errmsg("could not perform LDAP bind for credential validation of ldapbinddn \"%s\": %s", + hba->ldapbinddn ? hba->ldapbinddn : "", + ldap_err2string(r)), + errdetail_for_ldap(ldap))); + ldap_unbind(ldap); + return true; + } + + /* Build the same filter that was used at authentication time. */ + if (hba->ldapsearchfilter) + filter = FormatSearchFilter(hba->ldapsearchfilter, port->user_name); + else if (hba->ldapsearchattribute) + filter = psprintf("(%s=%s)", hba->ldapsearchattribute, port->user_name); + else + filter = psprintf("(uid=%s)", port->user_name); + +#ifndef WIN32 + { + struct timeval tv; + + tv.tv_sec = credential_validation_ldap_timeout; + tv.tv_usec = 0; + r = ldap_search_ext_s(ldap, hba->ldapbasedn, hba->ldapscope, + filter, attributes, 0, NULL, NULL, &tv, 0, + &search_message); + } +#else + r = ldap_search_s(ldap, hba->ldapbasedn, hba->ldapscope, + filter, attributes, 0, &search_message); +#endif + + if (r != LDAP_SUCCESS) + { + /* includes a timeout (LDAP_TIMEOUT): fail open like any other error */ + ereport(LOG, + (errmsg("could not search LDAP for filter \"%s\" during credential validation: %s", + filter, ldap_err2string(r)), + errdetail_for_ldap(ldap))); + if (search_message != NULL) + ldap_msgfree(search_message); + ldap_unbind(ldap); + pfree(filter); + return true; /* operational error; fail open */ + } + + count = ldap_count_entries(ldap, search_message); + + ldap_msgfree(search_message); + ldap_unbind(ldap); + pfree(filter); + + /* + * Zero entries is a definitive "user is gone"; terminate the session. An + * ambiguous (>1) result should not happen for an account that + * authenticated earlier, so treat it conservatively as still valid. + */ + return (count != 0); +} + /* * Add a detail error message text to the current error if one can be * constructed from the LDAP 'diagnostic message'. diff --git a/src/backend/utils/misc/guc_parameters.dat b/src/backend/utils/misc/guc_parameters.dat index ed352a4f49a..ad7602276a5 100644 --- a/src/backend/utils/misc/guc_parameters.dat +++ b/src/backend/utils/misc/guc_parameters.dat @@ -597,6 +597,16 @@ max => '60', }, +{ name => 'credential_validation_ldap_timeout', type => 'int', context => 'PGC_SU_BACKEND', group => 'CONN_AUTH_AUTH', + short_desc => 'Sets the maximum time in seconds that LDAP credential validation waits on the directory server.', + long_desc => 'The limit applies separately to connecting, binding and searching.', + flags => 'GUC_UNIT_S', + variable => 'credential_validation_ldap_timeout', + boot_val => '5', + min => '1', + max => '60', +}, + { name => 'cursor_tuple_fraction', type => 'real', context => 'PGC_USERSET', group => 'QUERY_TUNING_OTHER', short_desc => 'Sets the planner\'s estimate of the fraction of a cursor\'s rows that will be retrieved.', flags => 'GUC_EXPLAIN', diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index b7f7c86b954..3dd634cab01 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -935,6 +935,7 @@ #credential_validation_enabled = off # re-validate session credentials periodically #credential_validation_interval = 60 # revalidation interval in seconds (5-3600) +#credential_validation_ldap_timeout = 5 # max wait on the LDAP server per step, in seconds (1-60) #credential_validation_kdc_timeout = 5 # max wait on the Kerberos KDC, in seconds (1-60) #------------------------------------------------------------------------------ diff --git a/src/include/libpq/auth-validate.h b/src/include/libpq/auth-validate.h index 20944741441..85712ded684 100644 --- a/src/include/libpq/auth-validate.h +++ b/src/include/libpq/auth-validate.h @@ -25,6 +25,7 @@ typedef enum CredentialValidationType CVT_OAUTH = 0, /* OAuth bearer token authentication */ CVT_CERT, /* TLS client certificate authentication */ CVT_GSS, /* GSSAPI/Kerberos authentication */ + CVT_LDAP, /* LDAP authentication */ CVT_COUNT /* Total number of credential validation types */ } CredentialValidationType; diff --git a/src/include/libpq/auth.h b/src/include/libpq/auth.h index c8de59b9c31..535fdaeb8d9 100644 --- a/src/include/libpq/auth.h +++ b/src/include/libpq/auth.h @@ -35,6 +35,7 @@ extern PGDLLIMPORT char *pg_krb_server_keyfile; extern PGDLLIMPORT bool pg_krb_caseins_users; extern PGDLLIMPORT bool pg_gss_accept_delegation; +extern PGDLLIMPORT int credential_validation_ldap_timeout; extern PGDLLIMPORT int credential_validation_kdc_timeout; extern void ClientAuthentication(Port *port); @@ -63,4 +64,13 @@ extern PGDLLIMPORT auth_password_hook_typ ldap_password_hook; extern bool CheckKerberosPrincipalEnabled(Port *port, char *reason, size_t reasonlen); #endif +#ifdef USE_LDAP +/* + * Re-check that an LDAP-authenticated session's account is still valid in the + * directory. Used by continuous credential validation. Returns true if the + * session is still considered valid, false if the account is gone. + */ +extern bool CheckLDAPCredentialValidity(Port *port); +#endif + #endif /* AUTH_H */ diff --git a/src/test/ldap/meson.build b/src/test/ldap/meson.build index d8961e6c8d7..bdad7cb8409 100644 --- a/src/test/ldap/meson.build +++ b/src/test/ldap/meson.build @@ -9,6 +9,7 @@ tests += { 't/001_auth.pl', 't/002_bindpasswd.pl', 't/003_ldap_connection_param_lookup.pl', + 't/004_ldap_continuous_validation.pl', ], 'env': { 'with_ldap': ldap.found() ? 'yes' : 'no', diff --git a/src/test/ldap/t/004_ldap_continuous_validation.pl b/src/test/ldap/t/004_ldap_continuous_validation.pl new file mode 100644 index 00000000000..06d64dcef19 --- /dev/null +++ b/src/test/ldap/t/004_ldap_continuous_validation.pl @@ -0,0 +1,146 @@ + +# Copyright (c) 2021-2026, PostgreSQL Global Development Group + +# Test continuous credential validation for LDAP-authenticated sessions. +# +# Unlike OAuth/cert/GSS, an LDAP session retains no credential with an +# intrinsic expiry: the password presented at connection time is used for the +# bind and then discarded. With credential_validation_enabled, the backend +# should instead periodically re-check that the authenticated account still +# exists in the directory (and still matches the configured search filter), and +# terminate the session once it is gone. +# +# This test (search+bind mode) opens an LDAP-authenticated session, deletes the +# user's entry from the directory while the session sits idle, and then +# verifies that the next command is rejected with a FATAL "session credentials +# have expired". +# +# Like 001_auth.pl this requires a full OpenLDAP installation; see the README +# for details. + +use strict; +use warnings FATAL => 'all'; + +use FindBin; +use lib "$FindBin::RealBin/.."; + +use LdapServer; +use PostgreSQL::Test::Utils; +use PostgreSQL::Test::Cluster; +use Test::More; + +if ($ENV{with_ldap} ne 'yes') +{ + plan skip_all => 'LDAP not supported by this build'; +} +elsif (!$ENV{PG_TEST_EXTRA} || $ENV{PG_TEST_EXTRA} !~ /\bldap\b/) +{ + plan skip_all => + 'Potentially unsafe test LDAP not enabled in PG_TEST_EXTRA'; +} +elsif (!$LdapServer::setup) +{ + plan skip_all => $LdapServer::setup_error; +} + +# credential_validation_interval has a 5s minimum. The test waits for the +# termination to show up in the server log, not for a fixed time, so it takes +# at most one interval after the account is deleted. +my $validation_interval = 5; + +my $username = 'test1'; +my $user_dn = "uid=$username,dc=example,dc=net"; + +note "setting up LDAP server"; + +my $ldap_rootpw = 'secret'; +my $ldap = LdapServer->new($ldap_rootpw, 'anonymous'); # use anonymous auth +$ldap->ldapadd_file('authdata.ldif'); +$ldap->ldapsetpw($user_dn, 'secret1'); + +my ($ldap_server, $ldap_port, $ldap_basedn, $ldap_rootdn, $ldap_pwfile, + $ldap_url) + = $ldap->prop(qw(server port basedn rootdn pwfile url)); + +note "setting up PostgreSQL instance"; + +my $node = PostgreSQL::Test::Cluster->new('node'); +$node->init; +$node->append_conf( + 'postgresql.conf', qq{ +listen_addresses = '127.0.0.1' +log_connections = all +log_min_messages = debug2 +lc_messages = 'C' +credential_validation_enabled = on +credential_validation_interval = $validation_interval +credential_validation_ldap_timeout = 3 +}); +$node->start; + +$node->safe_psql('postgres', 'CREATE USER test1;'); + +unlink($node->data_dir . '/pg_hba.conf'); +$node->append_conf('pg_hba.conf', + qq{host all all 127.0.0.1/32 ldap ldapserver=$ldap_server ldapport=$ldap_port ldapbasedn="$ldap_basedn" ldapsearchfilter="(uid=\$username)"} +); +$node->restart; + +note "running tests"; + +# Open an LDAP-authenticated session and confirm it is live, then delete the +# user's directory entry and leave the session idle. Validation also runs +# while a session waits for its next command, so the session is terminated +# without being sent anything further: the re-search finds no entry. +my $connstr = + $node->connstr('postgres') . " user=$username host=127.0.0.1 sslmode=disable"; + +local $ENV{PGPASSWORD} = 'secret1'; + +my $session = $node->background_psql( + 'postgres', + connstr => $connstr, + on_error_stop => 0); + +my ($stdout, $ret) = $session->query("SELECT 'session-live';"); +like( + $stdout, + qr/session-live/, + 'session is live before the LDAP account is removed'); + +my $pid; +($stdout, $ret) = $session->query('SELECT pg_backend_pid();'); +$pid = $1 if $stdout =~ /(\d+)/; +ok(defined $pid, 'got the backend pid'); + +system_or_bail('ldapdelete', '-x', '-H', $ldap_url, '-D', $ldap_rootdn, + '-y', $ldap_pwfile, $user_dn); + +# Wait for the server to terminate the session, rather than sleeping a fixed +# time. The patterns are scoped to this backend's pid. +note "waiting for validation to notice that the account is gone..."; +ok( $node->wait_for_log( + qr/backend\[$pid\].*FATAL:.*session credentials have expired/), + 'session terminated with the credential-expiry FATAL'); + +# The server log, but not the client, says which check failed and for whom. +ok( $node->log_contains( + qr/backend\[$pid\].*DETAIL:.*LDAP check failed for user "$username": account no longer exists in the directory/ + ), + 'server log DETAIL identifies the user and the missing LDAP account'); + +# A command sent after termination must not return a result. +eval { ($stdout, $ret) = $session->query("SELECT 'after-expiry';"); }; +unlike( + $stdout // '', + qr/after-expiry/, + 'command after the account is removed does not return a result'); +eval { $session->quit; }; + +# The session must have actually authenticated via LDAP for this to be a +# meaningful test of LDAP credential validation. +ok( $node->log_contains( + qq{connection authenticated: identity="$user_dn" method=ldap}), + 'session was authenticated with LDAP'); + +done_testing(); -- 2.52.0