1 --- apache_1.3.12/src/modules/standard/mod_rewrite.c.wiget Wed Aug 23 17:32:28 2000
2 +++ apache_1.3.12/src/modules/standard/mod_rewrite.c Wed Aug 23 18:33:51 2000
11 ** +-------------------------------------------------------+
14 echo " (perhaps you need to add -ldbm, -lndbm or -lgdbm to EXTRA_LIBS)"
15 CFLAGS="$CFLAGS -DNO_DBM_REWRITEMAP"
17 + . ./helpers/find-ldap-lib
18 + if [ "x$found_ldap" = "x1" ]; then
19 + echo " enabling LDAP support for mod_rewrite"
21 + echo " disabling LDAP support for mod_rewrite"
22 + echo " (perhaps you need to add -llber -lldap to EXTRA_LIBS)"
23 + CFLAGS="$CFLAGS -DNO_LDAP_REWRITEMAP"
26 * MODULE-DEFINITION-END
29 "because no NDBM support is compiled in");
32 + else if (strncmp(a2, "ldap:", 4) == 0) {
33 +#ifndef NO_LDAP_REWRITEMAP
34 + new->type = MAPTYPE_LDAP;
36 +/* new->checkfile = ap_pstrcat(cmd->pool, a2+5, LDAP_FILE_SUFFIX, NULL); */
38 + return ap_pstrdup(cmd->pool, "RewriteMap: cannot use LDAP mapfile, "
39 + "because no LDAP support is compiled in");
42 else if (strncmp(a2, "prg:", 4) == 0) {
43 new->type = MAPTYPE_PRG;
45 @@ -2792,6 +2813,48 @@
49 + else if (s->type == MAPTYPE_LDAP) {
50 +#ifndef NO_LDAP_REWRITEMAP
52 +/* if (stat(s->checkfile, &st) == -1) {
53 + ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
54 + "mod_rewrite: can't access LDAP RewriteMap "
55 + "file %s", s->checkfile);
56 + rewritelog(r, 1, "can't open LDAP RewriteMap file, "
60 + rewritelog(r, 1, "MAPTYPE_LDAP: ok ");
61 + value = get_cache_string(cachep, s->name, CACHEMODE_TS,
63 + if (value == NULL) {
65 + "cache lookup FAILED, forcing new map lookup");
67 + lookup_map_ldap(r, s->datafile, key)) != NULL) {
68 + rewritelog(r, 5, "map lookup OK: map=%s[ldap] key=%s "
69 + "-> val=%s", s->name, key, value);
70 + set_cache_string(cachep, s->name, CACHEMODE_TS,
71 + st.st_mtime, key, value);
75 + rewritelog(r, 5, "map lookup FAILED: map=%s[ldap] "
76 + "key=%s", s->name, key);
77 + set_cache_string(cachep, s->name, CACHEMODE_TS,
78 + st.st_mtime, key, "");
83 + rewritelog(r, 5, "cache lookup OK: map=%s[ldap] key=%s "
84 + "-> val=%s", s->name, key, value);
85 + return value[0] != '\0' ? value : NULL;
91 else if (s->type == MAPTYPE_PRG) {
93 lookup_map_program(r, s->fpin, s->fpout, key)) != NULL) {
94 @@ -2929,6 +2992,71 @@
101 +#ifndef NO_LDAP_REWRITEMAP
103 +static char *lookup_map_ldap(request_rec *r, char *url, char *key)
105 +#define LDAP_URL_MAX 512
107 + LDAPMessage *msg, *entry;
112 + url_p = (char *)malloc((size_t)LDAP_URL_MAX);
113 + snprintf(url_p, LDAP_URL_MAX, url, key);
114 + ld=ldap_open("localhost", 389);
119 + res = ldap_simple_bind_s(ld,NULL,NULL);
120 + if (res!=LDAP_SUCCESS) {
126 + int ldap_url_search_s( ld, url, attrsonly, res )
132 + char *ldap_first_attribute(ld, entry, berptr)
134 + LDAPMessage *entry;
135 + BerElement **berptr;
139 + res = ldap_url_search_s(ld, url_p, 0, &msg );
141 + if ((res!=LDAP_SUCCESS) || !msg)
143 +/* ldap_perror(ld,"lookup_map_ldap"); */
147 + entry = ldap_first_entry(ld, msg);
153 + temp = ldap_get_values(ld, entry, "homedirectory");
158 + /* Assumes that the above ldap_get_values call only returns 1 value */
159 +/* strncpy(value, temp[0], (size_t)MAX_PATH); */
161 +/* return (char *)value; */
166 --- apache_1.3.12/src/modules/standard/mod_rewrite.h.wiget Thu Oct 21 22:45:38 1999
167 +++ apache_1.3.12/src/modules/standard/mod_rewrite.h Mon Jun 5 21:11:11 2000
169 #include <sys/locking.h>
172 +#ifndef NO_LDAP_REWRITEMAP
181 #define MAPTYPE_PRG 1<<2
182 #define MAPTYPE_INT 1<<3
183 #define MAPTYPE_RND 1<<4
184 +#define MAPTYPE_LDAP 1<<5
186 #define ENGINE_DISABLED 1<<0
187 #define ENGINE_ENABLED 1<<1
189 static char *lookup_map_txtfile(request_rec *r, char *file, char *key);
190 #ifndef NO_DBM_REWRITEMAP
191 static char *lookup_map_dbmfile(request_rec *r, char *file, char *key);
193 +#ifndef NO_LDAP_REWRITEMAP
194 +static char *lookup_map_ldap(request_rec *r, char *url, char *key);
196 static char *lookup_map_program(request_rec *r, int fpin,
197 int fpout, char *key);
198 --- /dev/null Tue May 5 22:32:27 1998
199 +++ apache_1.3.12/src/helpers/find-ldap-lib Wed Aug 23 18:32:53 2000
201 +if [ "x$found_ldap" = "x" ]; then
202 + if ./helpers/TestCompile func ldap_open; then
207 + if ./helpers/TestCompile lib "ldap -llber" ldap_open; then
208 + LDAP_LIB="-lldap -llber"
211 + if [ "x$found_ldap" = "x1" ]; then
212 + echo " + using $LDAP_LIB for LDAP support"