]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Added "modules.ldap.fail" for trigger
authorAlan T. DeKok <aland@freeradius.org>
Sun, 29 Apr 2012 13:17:09 +0000 (15:17 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 29 Apr 2012 13:17:09 +0000 (15:17 +0200)
raddb/trigger.conf
src/modules/rlm_ldap/rlm_ldap.c

index 6919e2ec4865fa8fb22bcbc7eb9aaa5e5dffa28d..12b9639811efd3745d4582bde860d1c302d6dab0 100644 (file)
@@ -177,6 +177,19 @@ trigger {
        #  module.  You can have module-specific triggers, by placing a
        #  "trigger" subsection in the module configuration.
        modules {
+               # The LDAP module
+               ldap {
+                       # Common arguments
+                       args = "radiusdModuleName s ldap' radiusdModuleInstance s ''"
+
+                       # Failed to open a new connection to the DB
+                       fail = "${snmptrap}::serverModuleConnectionFail ${args}"
+
+                       # There are no "open", "close", or "none" setting.
+                       # This is because the LDAP module re-connects and closes
+                       # the connection for every "bind as user" query.
+               }
+
                # The SQL module
                sql {
                        # Common arguments
@@ -211,6 +224,7 @@ trigger {
 # home_server.zombie
 # home_server_pool.fallback
 # home_server_pool.normal
+# modules.ldap.fail
 # modules.sql.close
 # modules.sql.fail
 # modules.sql.none
index 91d367a971e29cabcdb33826ead320e0e40619df..19ef5713718b255ba581440ff957de4a618682a6 100644 (file)
@@ -122,6 +122,7 @@ typedef struct ldap_conn {
 } LDAP_CONN;
 
 typedef struct {
+       CONF_SECTION   *cs;
        char           *server;
        int             port;
        int             timelimit;
@@ -436,6 +437,7 @@ ldap_instantiate(CONF_SECTION * conf, void **instance)
        memset(inst, 0, sizeof(*inst));
        inst->chase_referrals = 2; /* use OpenLDAP defaults */
        inst->rebind = 2;
+       inst->cs = conf;
 
        if (cf_section_parse(conf, inst, module_config) < 0) {
                free(inst);
@@ -2223,6 +2225,7 @@ static LDAP *ldap_connect(void *instance, const char *dn, const char *password,
 #ifdef HAVE_LDAP_INITIALIZE
                DEBUG("  [%s] (re)connect to %s, authentication %d", inst->xlat_name, inst->server, auth);
                if (ldap_initialize(&ld, inst->server) != LDAP_SUCCESS) {
+                       exec_trigger(NULL, inst->cs, "modules.ldap.fail");
                        radlog(L_ERR, "  [%s] ldap_initialize() failed", inst->xlat_name);
                        *result = RLM_MODULE_FAIL;
                        return (NULL);
@@ -2231,11 +2234,13 @@ static LDAP *ldap_connect(void *instance, const char *dn, const char *password,
        } else {
                DEBUG("  [%s] (re)connect to %s:%d, authentication %d", inst->xlat_name, inst->server, inst->port, auth);
                if ((ld = ldap_init(inst->server, inst->port)) == NULL) {
+                       exec_trigger(NULL, inst->cs, "modules.ldap.fail");
                        radlog(L_ERR, "  [%s] ldap_init() failed", inst->xlat_name);
                        *result = RLM_MODULE_FAIL;
                        return (NULL);
                }
        }
+
        tv.tv_sec = inst->net_timeout;
        tv.tv_usec = 0;
        if (ldap_set_option(ld, LDAP_OPT_NETWORK_TIMEOUT,
@@ -2425,6 +2430,7 @@ static LDAP *ldap_connect(void *instance, const char *dn, const char *password,
                               ldap_err2string(ldap_errno));
                        *result = RLM_MODULE_FAIL;
                        ldap_unbind_s(ld);
+                       exec_trigger(NULL, inst->cs, "modules.ldap.fail");
                        return (NULL);
                }
        }