You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the session length for an ldap connection seem pretty long (at least > 2 hours). This is problematic, because the session keeps being active, even if the bind password has been reset after the session has started.
So, we want to terminate ldap connections after 15 minutes or so. However, I can't find an option to do that.
Script to test this:
importtimefromdatetimeimportdatetimefromldap3importServer, Connection, ALL, Tls# ConfigurationLDAP_SERVER='ldaps://ldap.test.sram.surf.nl'# Replace with your LDAP server addressLDAP_PORT=636# Default port for LDAPSLDAP_USER='cn=admin,dc=123,dc=services,dc=sram-tst,dc=surf,dc=nl'# Replace with your LDAP bind DNLDAP_PASSWORD='the_password'SEARCH_BASE='dc=123,dc=services,dc=sram-tst,dc=surf,dc=nl'# Base DN for the searchSEARCH_FILTER='(objectClass=person)'# Adjust filter as neededSEARCH_ATTRIBUTES= ['uid', 'mail'] # Attributes to retrieve# TLS configuration (optional)tls_config=Tls()
try:
# Initialize server and connectionserver=Server(LDAP_SERVER, port=LDAP_PORT, use_ssl=True, get_info=ALL, tls=tls_config)
conn=Connection(server, user=LDAP_USER, password=LDAP_PASSWORD, auto_bind=True)
print("Connected to the LDAP server successfully.")
# Keep the session open and run queries periodicallyi=0whilei:=i+1:
conn.search(search_base=SEARCH_BASE,
search_filter=SEARCH_FILTER,
attributes=SEARCH_ATTRIBUTES)
print(f"{i: 4d}{datetime.now()} Search results ({len(conn.entries)} entries found)")
# Wait for 10 seconds before the next querytime.sleep(60)
exceptExceptionase:
print(f"An error occurred: {e}")
finally:
if'conn'inlocals() andconn.bound:
conn.unbind()
print("LDAP connection closed.")
The text was updated successfully, but these errors were encountered:
Currently, the session length for an ldap connection seem pretty long (at least > 2 hours). This is problematic, because the session keeps being active, even if the bind password has been reset after the session has started.
So, we want to terminate ldap connections after 15 minutes or so. However, I can't find an option to do that.
Script to test this:
The text was updated successfully, but these errors were encountered: