LDAP Settings (Python)

LDAP Settings (Python)
 1# This example shows how to retrieve LDAP settings for a database.
 2
 3db = impact.active_database
 4ot = impact.gui.output_toolbox
 5ot.clear()
 6
 7# Determine if LDAP enabled for the connected database
 8ot.add("LDAP Enabled (Connected): " + str(db.ldap_settings.enabled))
 9
10# Determine if LDAP enabled for a disconnected database. This can be used
11# to determine the LDAP settings before attempting a user login
12db = None
13try:
14    db = impact.databases.item("Production database")
15except Exception as exc:
16    impact.gui.output_toolbox.add(f"Failed to create object via impact.databases.item(): {exc}")
17if db.isNone():
18    ot.add("Unable to locate database")
19else:
20
21    # Warning this may fail with E_FAIL if the database cannot be contacted
22    ot.add("LDAP Enabled (Disconnected): " + db.ldap_settings.enabled)