util_ldap.c revision 3f5585f7f4a7d74f2f94ec729ea8c1879d419e35
55cf6e01272ec475edea32aa9b7923de2d36cb42Christian Maeder/* Licensed to the Apache Software Foundation (ASF) under one or more
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * contributor license agreements. See the NOTICE file distributed with
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * this work for additional information regarding copyright ownership.
b43458b4d81f7451112cecbd757f3a05216e7088Kristina Sojakova * The ASF licenses this file to You under the Apache License, Version 2.0
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * (the "License"); you may not use this file except in compliance with
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * the License. You may obtain a copy of the License at
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * http://www.apache.org/licenses/LICENSE-2.0
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * Unless required by applicable law or agreed to in writing, software
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * distributed under the License is distributed on an "AS IS" BASIS,
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * See the License for the specific language governing permissions and
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * limitations under the License.
b2e01ef1b5d4c7a62260eb792291e8e1b10e545bIulia Ignatov * util_ldap.c: LDAP things
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * Original code from auth_ldap module for Apache v1.3:
9f85afecbd79b3df5a0bb17bd28cd0b288dc3213Kristina Sojakova * Copyright 1998, 1999 Enbridge Pipelines Inc.
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova * Copyright 1999-2001 Dave Carrigan
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova#error mod_ldap requires APR-util to have LDAP support built in
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder/* Default define for ldap functions that need a SIZELIMIT but
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder * do not have the define
a65c6747c9acbbebc93baba7bae94d2e3d8cdafbTill Mossakowski * XXX This should be removed once a supporting #define is
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova * released through APR-Util.
a669e4685b32ff5ca1bca785eacc5e30a545b010Christian Maeder apr_global_mutex_lock(st->util_ldap_cache_lock); \
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova apr_global_mutex_unlock(st->util_ldap_cache_lock); \
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakovastatic void util_ldap_strdup (char **str, const char *newstr)
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova * Status Handler
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova * --------------
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova * This handler generates a status page about the current performance of
a669e4685b32ff5ca1bca785eacc5e30a545b010Christian Maeder * the LDAP cache. It is enabled as follows:
a669e4685b32ff5ca1bca785eacc5e30a545b010Christian Maeder * <Location /ldap-status>
d71bb9deea089887b4fd829c5b766e7e4de9f204Kristina Sojakova * SetHandler ldap-status
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakovastatic int util_ldap_handler(request_rec *r)
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova util_ldap_state_t *st = (util_ldap_state_t *)
abd5fc85dc7e19b1614890182436940e922963a4Kristina Sojakova ap_get_module_config(r->server->module_config,
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova "<html><head><title>LDAP Cache Information</title></head>\n", r);
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova ap_rputs("<body bgcolor='#ffffff'><h1 align=center>LDAP Cache Information"
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova "</h1>\n", r);
5e35940c3516ccea02caa0450d2b075de0106fa5Kristina Sojakova/* ------------------------------------------------------------------ */
b2e01ef1b5d4c7a62260eb792291e8e1b10e545bIulia Ignatov * Closes an LDAP connection by unlocking it. The next time
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder * uldap_connection_find() is called this connection will be
#if APR_HAS_THREADS
if (ldc) {
return APR_SUCCESS;
if (ldc) {
return APR_SUCCESS;
&ldap_module);
&(result));
#ifdef APR_LDAP_OPT_VERIFY_CERT
#if defined(LDAPSSL_VERIFY_SERVER)
int i = LDAP_OPT_X_TLS_DEMAND;
int i = LDAP_OPT_X_TLS_NEVER;
#ifdef LDAP_OPT_NETWORK_TIMEOUT
return(rc);
int rc = 0;
int failures = 0;
if (!ldc) {
return LDAP_SUCCESS;
return rc;
return(rc);
static util_ldap_connection_t *
&ldap_module);
#if APR_HAS_THREADS
#if APR_HAS_THREADS
#if APR_HAS_THREADS
#if APR_HAS_THREADS
l->bound = 0;
#if APR_HAS_THREADS
#if APR_HAS_THREADS
l->bound = 0;
p->next = l;
#if APR_HAS_THREADS
int result = 0;
int failures = 0;
char *searchdn;
&ldap_module);
if (!compare_dn_on_server) {
return LDAP_COMPARE_FALSE;
return LDAP_COMPARE_TRUE;
if (curl) {
return LDAP_COMPARE_TRUE;
return result;
return result;
== LDAP_SERVER_DOWN)
goto start_over;
return result;
if (curl) {
return result;
int result = 0;
int failures = 0;
&ldap_module);
if (curl) {
return result;
return result;
return result;
(char *)dn,
(char *)attrib,
(char *)value))
== LDAP_SERVER_DOWN) {
goto start_over;
if (curl) {
void *junk;
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "[%" APR_PID_T_FMT "] cache_compare: Cache insertion failure.", getpid());
return LDAP_COMPARE_TRUE;
return LDAP_COMPARE_FALSE;
return LDAP_NO_SUCH_ATTRIBUTE;
return result;
int failures = 0;
&ldap_module);
int base_sgcIndex = 0;
int lcl_sgl_processedFlag = 0;
struct mod_auth_ldap_groupattr_entry_t *sgc_ents = (struct mod_auth_ldap_groupattr_entry_t *) subgroupclasses->elts;
return result;
return LDAP_COMPARE_FALSE;
tmp_local_sgl->subgroupDNs = apr_pcalloc(r->pool, sizeof(char *) * compare_nodep->subgroupList->len);
return LDAP_COMPARE_FALSE;
return result;
return result;
goto start_over;
return result;
if (subgroupAttrs) {
char **values;
int val_index = 0;
if (values) {
val_index = 0;
tmp_sgcIndex = 0;
tmp_sgcIndex++;
val_index++;
indx++;
int sgindex;
char **group;
return LDAP_COMPARE_FALSE;
if (tmp_local_sgl) {
if (tmp_local_sgl) {
int sgindex = 0;
sgindex++;
return result;
const char ***retvals)
int numvals = 0;
int result = 0;
char *dn;
int count;
int failures = 0;
&ldap_module);
&curnode);
if (curl) {
return LDAP_SUCCESS;
return result;
return result;
== LDAP_SERVER_DOWN)
goto start_over;
return result;
if (count == 0 )
return LDAP_NO_SUCH_OBJECT;
return LDAP_INVALID_CREDENTIALS;
(char *)*binddn,
goto start_over;
return result;
if (attrs) {
while (attrs[k++]);
numvals = k;
while (attrs[i]) {
char **values;
if (curl) {
return LDAP_SUCCESS;
int numvals = 0;
int result = 0;
char *dn;
int count;
int failures = 0;
&ldap_module);
&curnode);
if (curl) {
return LDAP_SUCCESS;
return result;
return result;
== LDAP_SERVER_DOWN)
goto start_over;
return result;
if (count == 0 )
return LDAP_NO_SUCH_OBJECT;
if (attrs) {
while (attrs[k++]);
numvals = k;
while (attrs[i]) {
char **values;
if (curl) {
return LDAP_SUCCESS;
const char *bytes)
&ldap_module);
return err;
return NULL;
const char *file)
&ldap_module);
return err;
if (file) {
return NULL;
const char *ttl)
&ldap_module);
return err;
return NULL;
const char *size)
&ldap_module);
return err;
return NULL;
const char *ttl)
&ldap_module);
return err;
return NULL;
const char *size)
&ldap_module);
return err;
return NULL;
return APR_LDAP_CA_TYPE_DER;
return APR_LDAP_CA_TYPE_BASE64;
return APR_LDAP_CA_TYPE_CERT7_DB;
return APR_LDAP_CA_TYPE_SECMOD;
return APR_LDAP_CERT_TYPE_DER;
return APR_LDAP_CERT_TYPE_BASE64;
return APR_LDAP_CERT_TYPE_PFX;
return APR_LDAP_CERT_TYPE_KEY3_DB;
return APR_LDAP_CERT_TYPE_NICKNAME;
return APR_LDAP_KEY_TYPE_DER;
return APR_LDAP_KEY_TYPE_BASE64;
return APR_LDAP_KEY_TYPE_PFX;
return APR_LDAP_CA_TYPE_UNKNOWN;
void *dummy,
const char *type,
const char *file,
const char *password)
&ldap_module);
int cert_type = 0;
return err;
if (type) {
!= APR_SUCCESS))
return(NULL);
void *config,
const char *type,
const char *file,
const char *password)
&ldap_module);
int cert_type = 0;
if (type) {
type);
!= APR_SUCCESS))
return(NULL);
const char *mode)
&ldap_module);
mode);
return(NULL);
void *dummy,
int mode)
&ldap_module);
return err;
return(NULL);
void *dummy,
const char *ttl)
&ldap_module);
return err;
#ifdef LDAP_OPT_NETWORK_TIMEOUT
return NULL;
#if APR_HAS_THREADS
return st;
void *overridesv)
#if APR_HAS_THREADS
return st;
return APR_SUCCESS;
&ldap_module);
void *data;
int rc;
if (!data) {
NULL);
return OK;
return DONE;
NULL);
return result;
#ifdef AP_NEED_SET_MUTEX_PERMS
return result;
while (s_vhost) {
&ldap_module);
NULL,
&(result_err));
return(OK);
&ldap_module);
{NULL}