--- mod_authnz_ldap-old.c 2009-09-12 08:13:25.000000000 -0400 +++ mod_authnz_ldap.c 2009-09-14 14:37:13.000000000 -0400 @@ -184,6 +184,13 @@ apr_size_t inbytes; apr_size_t outbytes; char *outbuf; + + time_t now; + char formatedtime[1024]; + char outputbuffer[FILTER_LENGTH]; + const char *inp; + int outi; + struct tm *tp; if (sent_user != NULL) { user = apr_pstrdup (r->pool, sent_user); @@ -211,12 +218,43 @@ user = apr_pstrdup(r->pool, outbuf); } } + +#define addstring(w) \ +outi += snprintf(&outputbuffer[outi], FILTER_LENGTH - outi, "%s", w) + + memset(outputbuffer, 0, FILTER_LENGTH); + outi = 0; inp = filter; + + while ((*inp) && (outi < (FILTER_LENGTH - 1))) { + if (*inp != '$') { + outputbuffer[outi++] = *inp++; + } else { + inp++; + switch (*inp) { + case 't': + time(&now); + tp = localtime(&now); + strftime(formatedtime, sizeof(formatedtime), + "%Y%m%d%H%M%S", tp); + addstring(formatedtime); + break; + default: + inp--; + outputbuffer[outi++] = *inp; + break; + } + inp++; + } + } + + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, + "[%" APR_PID_T_FMT "] auth_ldap authenticate: filter after template replace %s", getpid(), outputbuffer); /* * Create the first part of the filter, which consists of the * config-supplied portions. */ - apr_snprintf(filtbuf, FILTER_LENGTH, "(&(%s)(%s=", filter, sec->attribute); + apr_snprintf(filtbuf, FILTER_LENGTH, "(&(%s)(%s=", outputbuffer, sec->attribute); /* * Now add the client-supplied username to the filter, ensuring that any