]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add variable expansion to mod_xml_ldap
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 3 Apr 2015 19:14:14 +0000 (14:14 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Sat, 4 Apr 2015 09:39:35 +0000 (04:39 -0500)
src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c

index 2838eeba0e05ec3f73a9b18d55cce7571d4c583c..a3d805495c83445493795111a1f59109c057358e 100644 (file)
@@ -116,7 +116,7 @@ SWITCH_MODULE_DEFINITION(mod_xml_ldap, mod_xml_ldap_load, mod_xml_ldap_shutdown,
 static switch_xml_t xml_ldap_search(const char *section, const char *tag_name, const char *key_name, const char *key_value, switch_event_t *params,
                                                                        void *user_data);
 
-static switch_status_t trydir(switch_xml_t *, int *, LDAP *, char *, char *, xml_binding_t *);
+static switch_status_t trydir(switch_xml_t *, int *, LDAP *, char *, char *, xml_binding_t *, switch_event_t *params);
 static switch_status_t do_config(void);
 static switch_status_t trysearch(switch_xml_t *pxml, int *xoff, LDAP * ld, char *basedn, char *filter);
 void rec(switch_xml_t *, int *, LDAP * ld, char *);
@@ -353,7 +353,7 @@ static switch_status_t do_config(void)
 }
 
 
-static switch_status_t trydir(switch_xml_t *pxml, int *xoff, LDAP * ld, char *dir_domain, char *dir_exten, xml_binding_t *binding)
+static switch_status_t trydir(switch_xml_t *pxml, int *xoff, LDAP * ld, char *dir_domain, char *dir_exten, xml_binding_t *binding, switch_event_t *param_event)
 {
         switch_status_t ret = SWITCH_STATUS_FALSE;
         int off = *xoff;
@@ -373,6 +373,15 @@ static switch_status_t trydir(switch_xml_t *pxml, int *xoff, LDAP * ld, char *di
         basedn = switch_mprintf(binding->basedn, dir_domain);
         filter = switch_mprintf(binding->filter, dir_exten);
  
+               if (param_event) {
+                       char *expanded = switch_event_expand_headers(param_event, filter);
+                       
+                       if (expanded != filter) {
+                               free(filter);
+                               filter = expanded;
+                       }
+               }
+
         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "searching in basedn %s with filter %s\n", basedn, filter);
  
         if ((ldap_search_s(ld, basedn, LDAP_SCOPE_SUB, filter, NULL, 0, &msg) != LDAP_SUCCESS))
@@ -612,7 +621,7 @@ static switch_xml_t xml_ldap_search(const char *section, const char *tag_name, c
                 break;
 
         case XML_LDAP_DIRECTORY:
-                ret = trydir(&xml, &xoff, ld, dir_domain, dir_exten, binding);
+                       ret = trydir(&xml, &xoff, ld, dir_domain, dir_exten, binding, params);
                 break;
 
         case XML_LDAP_DIALPLAN: