1 /* ============================================================
2 * Copyright (c) 2003-2004, Ondrej Sury
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 * mod_vhost_ldap.c --- read virtual host config from LDAP directory
28 #include "http_config.h"
29 #include "http_core.h"
31 #include "http_request.h"
32 #include "apr_version.h"
34 #include "apr_strings.h"
35 #include "apr_reslist.h"
36 #include "util_ldap.h"
38 #if !defined(APU_HAS_LDAP) && !defined(APR_HAS_LDAP)
39 #error mod_vhost_ldap requires APR-util to have LDAP support built in
42 #if !defined(WIN32) && !defined(OS2) && !defined(BEOS) && !defined(NETWARE)
43 #define HAVE_UNIX_SUEXEC
46 #ifdef HAVE_UNIX_SUEXEC
47 #include "unixd.h" /* Contains the suexec_identity hook used on Unix */
53 module AP_MODULE_DECLARE_DATA vhost_ldap_module;
56 MVL_UNSET, MVL_DISABLED, MVL_ENABLED
57 } mod_vhost_ldap_status_e;
59 typedef struct mod_vhost_ldap_config_t {
60 mod_vhost_ldap_status_e enabled; /* Is vhost_ldap enabled? */
62 /* These parameters are all derived from the VhostLDAPURL directive */
63 char *url; /* String representation of LDAP URL */
65 char *host; /* Name of the LDAP server (or space separated list) */
66 int port; /* Port of the LDAP server */
67 char *basedn; /* Base DN to do all searches from */
68 int scope; /* Scope of the search */
69 char *filter; /* Filter to further limit the search */
70 deref_options deref; /* how to handle alias dereferening */
72 char *binddn; /* DN to bind to server (can be NULL) */
73 char *bindpw; /* Password to bind to server (can be NULL) */
75 int have_deref; /* Set if we have found an Deref option */
76 int have_ldap_url; /* Set if we have found an LDAP url */
78 int secure; /* True if SSL connections are requested */
80 char *fallback; /* Fallback virtual host */
82 } mod_vhost_ldap_config_t;
84 typedef struct mod_vhost_ldap_request_t {
85 char *dn; /* The saved dn from a successful search */
86 char *name; /* ServerName */
87 char *admin; /* ServerAdmin */
88 char *docroot; /* DocumentRoot */
89 char *cgiroot; /* ScriptAlias */
90 char *uid; /* Suexec Uid */
91 char *gid; /* Suexec Gid */
92 char *saved_docroot; /* Saved DocumentRoot */
93 } mod_vhost_ldap_request_t;
96 { "apacheServerName", "apacheDocumentRoot", "apacheScriptAlias", "apacheSuexecUid", "apacheSuexecGid", "apacheServerAdmin", 0 };
98 #if (APR_MAJOR_VERSION >= 1)
99 static APR_OPTIONAL_FN_TYPE(uldap_connection_close) *util_ldap_connection_close;
100 static APR_OPTIONAL_FN_TYPE(uldap_connection_find) *util_ldap_connection_find;
101 static APR_OPTIONAL_FN_TYPE(uldap_cache_comparedn) *util_ldap_cache_comparedn;
102 static APR_OPTIONAL_FN_TYPE(uldap_cache_compare) *util_ldap_cache_compare;
103 static APR_OPTIONAL_FN_TYPE(uldap_cache_checkuserid) *util_ldap_cache_checkuserid;
104 static APR_OPTIONAL_FN_TYPE(uldap_cache_getuserdn) *util_ldap_cache_getuserdn;
105 static APR_OPTIONAL_FN_TYPE(uldap_ssl_supported) *util_ldap_ssl_supported;
107 static void ImportULDAPOptFn(void)
109 util_ldap_connection_close = APR_RETRIEVE_OPTIONAL_FN(uldap_connection_close);
110 util_ldap_connection_find = APR_RETRIEVE_OPTIONAL_FN(uldap_connection_find);
111 util_ldap_cache_comparedn = APR_RETRIEVE_OPTIONAL_FN(uldap_cache_comparedn);
112 util_ldap_cache_compare = APR_RETRIEVE_OPTIONAL_FN(uldap_cache_compare);
113 util_ldap_cache_checkuserid = APR_RETRIEVE_OPTIONAL_FN(uldap_cache_checkuserid);
114 util_ldap_cache_getuserdn = APR_RETRIEVE_OPTIONAL_FN(uldap_cache_getuserdn);
115 util_ldap_ssl_supported = APR_RETRIEVE_OPTIONAL_FN(uldap_ssl_supported);
119 static int mod_vhost_ldap_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
121 /* make sure that mod_ldap (util_ldap) is loaded */
122 if (ap_find_linked_module("util_ldap.c") == NULL) {
123 ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, s,
124 "Module mod_ldap missing. Mod_ldap (aka. util_ldap) "
125 "must be loaded in order for mod_vhost_ldap to function properly");
126 return HTTP_INTERNAL_SERVER_ERROR;
130 ap_add_version_component(p, MOD_VHOST_LDAP_VERSION);
136 mod_vhost_ldap_create_server_config (apr_pool_t *p, server_rec *s)
138 mod_vhost_ldap_config_t *conf =
139 (mod_vhost_ldap_config_t *)apr_pcalloc(p, sizeof (mod_vhost_ldap_config_t));
141 conf->enabled = MVL_UNSET;
142 conf->have_ldap_url = 0;
143 conf->have_deref = 0;
146 conf->deref = always;
147 conf->fallback = NULL;
153 mod_vhost_ldap_merge_server_config(apr_pool_t *p, void *parentv, void *childv)
155 mod_vhost_ldap_config_t *parent = (mod_vhost_ldap_config_t *) parentv;
156 mod_vhost_ldap_config_t *child = (mod_vhost_ldap_config_t *) childv;
157 mod_vhost_ldap_config_t *conf =
158 (mod_vhost_ldap_config_t *)apr_pcalloc(p, sizeof(mod_vhost_ldap_config_t));
160 if (child->enabled == MVL_UNSET) {
161 conf->enabled = parent->enabled;
163 conf->enabled = child->enabled;
166 if (child->have_ldap_url) {
167 conf->have_ldap_url = child->have_ldap_url;
168 conf->url = child->url;
169 conf->host = child->host;
170 conf->port = child->port;
171 conf->basedn = child->basedn;
172 conf->scope = child->scope;
173 conf->filter = child->filter;
174 conf->secure = child->secure;
176 conf->have_ldap_url = parent->have_ldap_url;
177 conf->url = parent->url;
178 conf->host = parent->host;
179 conf->port = parent->port;
180 conf->basedn = parent->basedn;
181 conf->scope = parent->scope;
182 conf->filter = parent->filter;
183 conf->secure = parent->secure;
185 if (child->have_deref) {
186 conf->have_deref = child->have_deref;
187 conf->deref = child->deref;
189 conf->have_deref = parent->have_deref;
190 conf->deref = parent->deref;
193 conf->binddn = (child->binddn ? child->binddn : parent->binddn);
194 conf->bindpw = (child->bindpw ? child->bindpw : parent->bindpw);
196 conf->fallback = (child->fallback ? child->fallback : parent->fallback);
202 * Use the ldap url parsing routines to break up the ldap url into
205 static const char *mod_vhost_ldap_parse_url(cmd_parms *cmd,
210 apr_ldap_url_desc_t *urld;
211 #if (APR_MAJOR_VERSION >= 1)
212 apr_ldap_err_t *result_err;
215 mod_vhost_ldap_config_t *conf =
216 (mod_vhost_ldap_config_t *)ap_get_module_config(cmd->server->module_config,
219 ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0,
220 cmd->server, "[mod_vhost_ldap.c] url parse: `%s'",
223 #if (APR_MAJOR_VERSION >= 1) /* for apache >= 2.2 */
224 result = apr_ldap_url_parse(cmd->pool, url, &(urld), &(result_err));
225 if (result != LDAP_SUCCESS) {
226 return result_err->reason;
229 result = apr_ldap_url_parse(url, &(urld));
230 if (result != LDAP_SUCCESS) {
232 case LDAP_URL_ERR_NOTLDAP:
233 return "LDAP URL does not begin with ldap://";
234 case LDAP_URL_ERR_NODN:
235 return "LDAP URL does not have a DN";
236 case LDAP_URL_ERR_BADSCOPE:
237 return "LDAP URL has an invalid scope";
238 case LDAP_URL_ERR_MEM:
239 return "Out of memory parsing LDAP URL";
241 return "Could not parse LDAP URL";
245 conf->url = apr_pstrdup(cmd->pool, url);
247 ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0,
248 cmd->server, "[mod_vhost_ldap.c] url parse: Host: %s", urld->lud_host);
249 ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0,
250 cmd->server, "[mod_vhost_ldap.c] url parse: Port: %d", urld->lud_port);
251 ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0,
252 cmd->server, "[mod_vhost_ldap.c] url parse: DN: %s", urld->lud_dn);
253 ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0,
254 cmd->server, "[mod_vhost_ldap.c] url parse: attrib: %s", urld->lud_attrs? urld->lud_attrs[0] : "(null)");
255 ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0,
256 cmd->server, "[mod_vhost_ldap.c] url parse: scope: %s",
257 (urld->lud_scope == LDAP_SCOPE_SUBTREE? "subtree" :
258 urld->lud_scope == LDAP_SCOPE_BASE? "base" :
259 urld->lud_scope == LDAP_SCOPE_ONELEVEL? "onelevel" : "unknown"));
260 ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0,
261 cmd->server, "[mod_vhost_ldap.c] url parse: filter: %s", urld->lud_filter);
263 /* Set all the values, or at least some sane defaults */
265 char *p = apr_palloc(cmd->pool, strlen(conf->host) + strlen(urld->lud_host) + 2);
266 strcpy(p, urld->lud_host);
268 strcat(p, conf->host);
272 conf->host = urld->lud_host? apr_pstrdup(cmd->pool, urld->lud_host) : "localhost";
274 conf->basedn = urld->lud_dn? apr_pstrdup(cmd->pool, urld->lud_dn) : "";
276 conf->scope = urld->lud_scope == LDAP_SCOPE_ONELEVEL ?
277 LDAP_SCOPE_ONELEVEL : LDAP_SCOPE_SUBTREE;
279 if (urld->lud_filter) {
280 if (urld->lud_filter[0] == '(') {
282 * Get rid of the surrounding parens; later on when generating the
283 * filter, they'll be put back.
285 conf->filter = apr_pstrdup(cmd->pool, urld->lud_filter+1);
286 conf->filter[strlen(conf->filter)-1] = '\0';
289 conf->filter = apr_pstrdup(cmd->pool, urld->lud_filter);
293 conf->filter = "objectClass=apacheConfig";
296 /* "ldaps" indicates secure ldap connections desired
298 if (strncasecmp(url, "ldaps", 5) == 0)
301 conf->port = urld->lud_port? urld->lud_port : LDAPS_PORT;
302 ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, cmd->server,
303 "LDAP: vhost_ldap using SSL connections");
308 conf->port = urld->lud_port? urld->lud_port : LDAP_PORT;
309 ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, cmd->server,
310 "LDAP: vhost_ldap not using SSL connections");
313 conf->have_ldap_url = 1;
314 #if (APR_MAJOR_VERSION < 1) /* free only required for older apr */
315 apr_ldap_free_urldesc(urld);
320 static const char *mod_vhost_ldap_set_enabled(cmd_parms *cmd, void *dummy, int enabled)
322 mod_vhost_ldap_config_t *conf =
323 (mod_vhost_ldap_config_t *)ap_get_module_config(cmd->server->module_config,
326 conf->enabled = (enabled) ? MVL_ENABLED : MVL_DISABLED;
331 static const char *mod_vhost_ldap_set_binddn(cmd_parms *cmd, void *dummy, const char *binddn)
333 mod_vhost_ldap_config_t *conf =
334 (mod_vhost_ldap_config_t *)ap_get_module_config(cmd->server->module_config,
337 conf->binddn = apr_pstrdup(cmd->pool, binddn);
341 static const char *mod_vhost_ldap_set_bindpw(cmd_parms *cmd, void *dummy, const char *bindpw)
343 mod_vhost_ldap_config_t *conf =
344 (mod_vhost_ldap_config_t *)ap_get_module_config(cmd->server->module_config,
347 conf->bindpw = apr_pstrdup(cmd->pool, bindpw);
351 static const char *mod_vhost_ldap_set_deref(cmd_parms *cmd, void *dummy, const char *deref)
353 mod_vhost_ldap_config_t *conf =
354 (mod_vhost_ldap_config_t *)ap_get_module_config (cmd->server->module_config,
357 if (strcmp(deref, "never") == 0 || strcasecmp(deref, "off") == 0) {
359 conf->have_deref = 1;
361 else if (strcmp(deref, "searching") == 0) {
362 conf->deref = searching;
363 conf->have_deref = 1;
365 else if (strcmp(deref, "finding") == 0) {
366 conf->deref = finding;
367 conf->have_deref = 1;
369 else if (strcmp(deref, "always") == 0 || strcasecmp(deref, "on") == 0) {
370 conf->deref = always;
371 conf->have_deref = 1;
374 return "Unrecognized value for VhostLDAPAliasDereference directive";
379 static const char *mod_vhost_ldap_set_fallback(cmd_parms *cmd, void *dummy, const char *fallback)
381 mod_vhost_ldap_config_t *conf =
382 (mod_vhost_ldap_config_t *)ap_get_module_config(cmd->server->module_config,
385 conf->fallback = apr_pstrdup(cmd->pool, fallback);
389 command_rec mod_vhost_ldap_cmds[] = {
390 AP_INIT_TAKE1("VhostLDAPURL", mod_vhost_ldap_parse_url, NULL, RSRC_CONF,
391 "URL to define LDAP connection. This should be an RFC 2255 compliant\n"
392 "URL of the form ldap://host[:port]/basedn[?attrib[?scope[?filter]]].\n"
394 "<li>Host is the name of the LDAP server. Use a space separated list of hosts \n"
395 "to specify redundant servers.\n"
396 "<li>Port is optional, and specifies the port to connect to.\n"
397 "<li>basedn specifies the base DN to start searches from\n"
400 AP_INIT_TAKE1 ("VhostLDAPBindDN", mod_vhost_ldap_set_binddn, NULL, RSRC_CONF,
401 "DN to use to bind to LDAP server. If not provided, will do an anonymous bind."),
403 AP_INIT_TAKE1("VhostLDAPBindPassword", mod_vhost_ldap_set_bindpw, NULL, RSRC_CONF,
404 "Password to use to bind to LDAP server. If not provided, will do an anonymous bind."),
406 AP_INIT_FLAG("VhostLDAPEnabled", mod_vhost_ldap_set_enabled, NULL, RSRC_CONF,
407 "Set to off to disable vhost_ldap, even if it's been enabled in a higher tree"),
409 AP_INIT_TAKE1("VhostLDAPDereferenceAliases", mod_vhost_ldap_set_deref, NULL, RSRC_CONF,
410 "Determines how aliases are handled during a search. Can be one of the"
411 "values \"never\", \"searching\", \"finding\", or \"always\". "
412 "Defaults to always."),
414 AP_INIT_TAKE1("VhostLDAPFallback", mod_vhost_ldap_set_fallback, NULL, RSRC_CONF,
415 "Set default virtual host which will be used when requested hostname"
416 "is not found in LDAP database. This option can be used to display"
417 "\"virtual host not found\" type of page."),
422 #define FILTER_LENGTH MAX_STRING_LEN
423 static int mod_vhost_ldap_translate_name(request_rec *r)
425 request_rec *top = (r->main)?r->main:r;
426 mod_vhost_ldap_request_t *reqc;
429 const char **vals = NULL;
430 char filtbuf[FILTER_LENGTH];
431 mod_vhost_ldap_config_t *conf =
432 (mod_vhost_ldap_config_t *)ap_get_module_config(r->server->module_config, &vhost_ldap_module);
433 util_ldap_connection_t *ldc = NULL;
435 const char *dn = NULL;
437 const char *hostname = NULL;
441 (mod_vhost_ldap_request_t *)apr_pcalloc(r->pool, sizeof(mod_vhost_ldap_request_t));
442 memset(reqc, 0, sizeof(mod_vhost_ldap_request_t));
444 ap_set_module_config(r->request_config, &vhost_ldap_module, reqc);
446 // mod_vhost_ldap is disabled or we don't have LDAP Url
447 if ((conf->enabled != MVL_ENABLED)||(!conf->have_ldap_url)) {
454 ldc = util_ldap_connection_find(r, conf->host, conf->port,
455 conf->binddn, conf->bindpw, conf->deref,
459 ap_log_rerror(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, 0, r,
460 "[mod_vhost_ldap.c] translate: no conf->host - weird...?");
461 return HTTP_INTERNAL_SERVER_ERROR;
464 hostname = r->hostname;
468 ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r,
469 "[mod_vhost_ldap.c]: translating %s", r->uri);
471 apr_snprintf(filtbuf, FILTER_LENGTH, "(&(%s)(|(apacheServerName=%s)(apacheServerAlias=%s)))", conf->filter, hostname, hostname);
473 result = util_ldap_cache_getuserdn(r, ldc, conf->url, conf->basedn, conf->scope,
474 attributes, filtbuf, &dn, &vals);
476 util_ldap_connection_close(ldc);
478 /* sanity check - if server is down, retry it up to 5 times */
479 if (result == LDAP_SERVER_DOWN) {
480 if (failures++ <= 5) {
483 return HTTP_GATEWAY_TIME_OUT;
487 if (result == LDAP_NO_SUCH_OBJECT) {
488 if (conf->fallback && (is_fallback++ <= 0)) {
489 ap_log_rerror(APLOG_MARK, APLOG_NOTICE|APLOG_NOERRNO, 0, r,
490 "[mod_vhost_ldap.c] translate: "
491 "virtual host %s not found, trying fallback %s",
492 hostname, conf->fallback);
493 hostname = conf->fallback;
497 ap_log_rerror(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, 0, r,
498 "[mod_vhost_ldap.c] translate: "
499 "virtual host %s not found",
502 return HTTP_BAD_REQUEST;
505 /* handle bind failure */
506 if (result != LDAP_SUCCESS) {
507 ap_log_rerror(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, 0, r,
508 "[mod_vhost_ldap.c] translate: "
509 "translate failed; virtual host %s; URI %s [%s]",
510 hostname, r->uri, ldap_err2string(result));
511 return HTTP_INTERNAL_SERVER_ERROR;
514 /* mark the user and DN */
515 reqc->dn = apr_pstrdup(r->pool, dn);
520 while (attributes[i]) {
522 if (strcasecmp (attributes[i], "apacheServerName") == 0) {
523 reqc->name = apr_pstrdup (r->pool, vals[i]);
525 else if (strcasecmp (attributes[i], "apacheServerAdmin") == 0) {
526 reqc->admin = apr_pstrdup (r->pool, vals[i]);
528 else if (strcasecmp (attributes[i], "apacheDocumentRoot") == 0) {
529 reqc->docroot = apr_pstrdup (r->pool, vals[i]);
531 else if (strcasecmp (attributes[i], "apacheScriptAlias") == 0) {
532 reqc->cgiroot = apr_pstrdup (r->pool, vals[i]);
534 else if (strcasecmp (attributes[i], "apacheSuexecUid") == 0) {
535 reqc->uid = apr_pstrdup(r->pool, vals[i]);
537 else if (strcasecmp (attributes[i], "apacheSuexecGid") == 0) {
538 reqc->gid = apr_pstrdup(r->pool, vals[i]);
544 ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r,
545 "[mod_vhost_ldap.c]: loaded from ldap: "
546 "apacheServerName: %s, "
547 "apacheServerAdmin: %s, "
548 "apacheDocumentRoot: %s, "
549 "apacheScriptAlias: %s, "
550 "apacheSuexecUid: %s, "
551 "apacheSuexecGid: %s",
552 reqc->name, reqc->admin, reqc->docroot, reqc->cgiroot, reqc->uid, reqc->gid);
554 if ((reqc->name == NULL)||(reqc->docroot == NULL)) {
555 ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r,
556 "[mod_vhost_ldap.c] translate: "
557 "translate failed; ServerName or DocumentRoot not defined");
558 return HTTP_INTERNAL_SERVER_ERROR;
564 cgi = strstr(r->uri, "cgi-bin/");
565 if (cgi && (cgi != r->uri + strspn(r->uri, "/"))) {
570 r->filename = apr_pstrcat (r->pool, reqc->cgiroot, cgi + strlen("cgi-bin"), NULL);
571 r->handler = "cgi-script";
572 apr_table_setn(r->notes, "alias-forced-type", r->handler);
573 } else if (r->uri[0] == '/') {
574 /* r->filename = apr_pstrdup(r->pool, r->uri); */
575 /* r->filename = apr_pstrcat (r->pool, reqc->docroot, r->uri, NULL); */
580 top->server->server_hostname = apr_pstrdup (top->pool, reqc->name);
583 top->server->server_admin = apr_pstrdup (top->pool, reqc->admin);
586 ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r,
587 "[mod_vhost_ldap.c]: ap_document_root is: %s", ap_document_root(r));
589 reqc->saved_docroot = apr_pstrdup(top->pool, ap_document_root(r));
591 set_document_root(r, NULL, reqc->docroot);
593 ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r,
594 "[mod_vhost_ldap.c]: ap_document_root set to: %s", ap_document_root(r));
596 // set environment variables
597 e = top->subprocess_env;
598 apr_table_addn (e, "SERVER_ROOT", reqc->docroot);
599 apr_table_addn (e, "DOCUMENT_ROOT", reqc->docroot);
601 /* Hack to allow post-processing by other modules (mod_rewrite, mod_alias) */
605 static int mod_vhost_ldap_cleanup(request_rec * r)
607 mod_vhost_ldap_request_t *reqc =
608 (mod_vhost_ldap_request_t *)ap_get_module_config(r->request_config,
611 set_document_root(r, NULL, reqc->saved_docroot);
613 ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r,
614 "[mod_vhost_ldap.c]: ap_document_root restored to: %s", ap_document_root(r));
619 #ifdef HAVE_UNIX_SUEXEC
620 static ap_unix_identity_t *mod_vhost_ldap_get_suexec_id_doer(const request_rec * r)
622 ap_unix_identity_t *ugid = NULL;
623 mod_vhost_ldap_config_t *conf =
624 (mod_vhost_ldap_config_t *)ap_get_module_config(r->server->module_config,
626 mod_vhost_ldap_request_t *req =
627 (mod_vhost_ldap_request_t *)ap_get_module_config(r->request_config,
633 // mod_vhost_ldap is disabled or we don't have LDAP Url
634 if ((conf->enabled != MVL_ENABLED)||(!conf->have_ldap_url)) {
638 if ((req == NULL)||(req->uid == NULL)||(req->gid == NULL)) {
642 if ((ugid = apr_palloc(r->pool, sizeof(ap_unix_identity_t))) == NULL) {
646 uid = (uid_t)atoll(req->uid);
647 gid = (gid_t)atoll(req->gid);
649 if ((uid < MIN_UID)||(gid < MIN_GID)) {
662 mod_vhost_ldap_register_hooks (apr_pool_t * p)
666 * Run before mod_rewrite
668 static const char * const aszRewrite[]={ "mod_rewrite.c", NULL };
670 ap_hook_post_config(mod_vhost_ldap_post_config, NULL, NULL, APR_HOOK_MIDDLE);
671 ap_hook_translate_name(mod_vhost_ldap_translate_name, NULL, aszRewrite, APR_HOOK_FIRST);
672 ap_hook_fixups(mod_vhost_ldap_cleanup, aszRewrite, NULL, APR_HOOK_MIDDLE);
673 #ifdef HAVE_UNIX_SUEXEC
674 ap_hook_get_suexec_identity(mod_vhost_ldap_get_suexec_id_doer, NULL, NULL, APR_HOOK_MIDDLE);
676 #if (APR_MAJOR_VERSION >= 1)
677 ap_hook_optional_fn_retrieve(ImportULDAPOptFn,NULL,NULL,APR_HOOK_MIDDLE);
681 module AP_MODULE_DECLARE_DATA vhost_ldap_module = {
682 STANDARD20_MODULE_STUFF,
685 mod_vhost_ldap_create_server_config,
686 mod_vhost_ldap_merge_server_config,
688 mod_vhost_ldap_register_hooks,