util_ldap.h revision de08bde119ad74b6001b174369d563abcbe68c24
08cb74ca432a8c24e39f17dedce527e6a47b8001jerenkrantz/* ====================================================================
08cb74ca432a8c24e39f17dedce527e6a47b8001jerenkrantz * The Apache Software License, Version 1.1
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * reserved.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * Redistribution and use in source and binary forms, with or without
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * modification, are permitted provided that the following conditions
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * are met:
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * 1. Redistributions of source code must retain the above copyright
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * notice, this list of conditions and the following disclaimer.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * 2. Redistributions in binary form must reproduce the above copyright
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * notice, this list of conditions and the following disclaimer in
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * the documentation and/or other materials provided with the
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * distribution.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * 3. The end-user documentation included with the redistribution,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * if any, must include the following acknowledgment:
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * "This product includes software developed by the
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * Apache Software Foundation (http://www.apache.org/)."
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * Alternately, this acknowledgment may appear in the software itself,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * if and wherever such third-party acknowledgments normally appear.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * 4. The names "Apache" and "Apache Software Foundation" must
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * not be used to endorse or promote products derived from this
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * software without prior written permission. For written
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * permission, please contact apache@apache.org.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * 5. Products derived from this software may not be called "Apache",
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * nor may "Apache" appear in their name, without prior written
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * permission of the Apache Software Foundation.
5c0419d51818eb02045cf923a9fe456127a44c60wrowe *
5c0419d51818eb02045cf923a9fe456127a44c60wrowe * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
d266c3777146d36a4c23c17aad6f153aebea1bf4jorton * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
d266c3777146d36a4c23c17aad6f153aebea1bf4jorton * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
d266c3777146d36a4c23c17aad6f153aebea1bf4jorton * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
d266c3777146d36a4c23c17aad6f153aebea1bf4jorton * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * SUCH DAMAGE.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * ====================================================================
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes *
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * This software consists of voluntary contributions made by many
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * individuals on behalf of the Apache Software Foundation. For more
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * information on the Apache Software Foundation, please see
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * <http://www.apache.org/>.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#ifndef UTIL_LDAP_H
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#define UTIL_LDAP_H
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#include <apr_ldap.h>
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/* this whole thing disappears if LDAP is not enabled */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#ifdef APU_HAS_LDAP
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/* APR header files */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#include <apr_thread_mutex.h>
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#include <apr_thread_rwlock.h>
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#include <apr_tables.h>
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#include <apr_time.h>
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/* Apache header files */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#include "ap_config.h"
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#include "httpd.h"
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#include "http_config.h"
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#include "http_core.h"
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#include "http_log.h"
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#include "http_protocol.h"
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#include "http_request.h"
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/*
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * LDAP Connections
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/* Values that the deref member can have */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholestypedef enum {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes never=LDAP_DEREF_NEVER,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes searching=LDAP_DEREF_SEARCHING,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes finding=LDAP_DEREF_FINDING,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes always=LDAP_DEREF_ALWAYS
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes} deref_options;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/* Structure representing an LDAP connection */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholestypedef struct util_ldap_connection_t {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes LDAP *ldap;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_pool_t *pool; /* Pool from which this connection is created */
f8fc4173f3b9715e5945b668ba511b77573dc1d1minfrin apr_thread_mutex_t *lock; /* Lock to indicate this connection is in use */
f8fc4173f3b9715e5945b668ba511b77573dc1d1minfrin int bound; /* Flag to indicate whether this connection is bound yet */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
f8fc4173f3b9715e5945b668ba511b77573dc1d1minfrin const char *host; /* Name of the LDAP server (or space separated list) */
f8fc4173f3b9715e5945b668ba511b77573dc1d1minfrin int port; /* Port of the LDAP server */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes deref_options deref; /* how to handle alias dereferening */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes const char *binddn; /* DN to bind to server (can be NULL) */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes const char *bindpw; /* Password to bind to server (can be NULL) */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int netscapessl; /* True if use Netscape SSL connection */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes const char *certtdb; /* Path to Netscape CA database */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int starttls; /* True if StartTLS is enabled */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int withtls; /* True if StartTLS on this connection */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes const char *reason; /* Reason for an error failure */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes struct util_ldap_connection_t *next;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes} util_ldap_connection_t;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/* LDAP cache state information */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholestypedef struct util_ldap_state_t {
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_pool_t *pool; /* pool from which this state is allocated */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_thread_mutex_t *mutex; /* mutex lock for the connection list */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes apr_size_t cache_bytes; /* Size (in bytes) of shared memory cache */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes long search_cache_ttl; /* TTL for search cache */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes long search_cache_size; /* Size (in entries) of search cache */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes long compare_cache_ttl; /* TTL for compare cache */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes long compare_cache_size; /* Size (in entries) of compare cache */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes struct util_ldap_connection_t *connections;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#ifdef APU_HAS_LDAP_NETSCAPE_SSL
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int have_certdb;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes#endif
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes} util_ldap_state_t;
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/**
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * Open a connection to an LDAP server
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param ldc A structure containing the expanded details of the server
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * to connect to. The handle to the LDAP connection is returned
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * as ldc->ldap.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @tip This function connects to the LDAP server and binds. It does not
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * connect if already connected (ldc->ldap != NULL). Does not bind
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * if already bound.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @return If successful LDAP_SUCCESS is returned.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @deffunc int util_ldap_connection_open(util_ldap_connection_t *ldc)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholesint util_ldap_connection_open(util_ldap_connection_t *ldc);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/**
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * Close a connection to an LDAP server
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param ldc A structure containing the expanded details of the server
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * that was connected.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @tip This function unbinds from the LDAP server, and clears ldc->ldap.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * It is possible to rebind to this server again using the same ldc
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * structure, using apr_ldap_open_connection().
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @deffunc util_ldap_close_connection(util_ldap_connection_t *ldc)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholesvoid util_ldap_connection_close(util_ldap_connection_t *ldc);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/**
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * Destroy a connection to an LDAP server
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param ldc A structure containing the expanded details of the server
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * that was connected.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @tip This function is registered with the pool cleanup to close down the
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * LDAP connections when the server is finished with them.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @deffunc apr_status_t util_ldap_connection_destroy(util_ldap_connection_t *ldc)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholesapr_status_t util_ldap_connection_destroy(void *param);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/**
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * Find a connection in a list of connections
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param r The request record
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param host The hostname to connect to (multiple hosts space separated)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param port The port to connect to
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param binddn The DN to bind with
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param bindpw The password to bind with
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param deref The dereferencing behavior
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param netscapessl Start SSL on the connection using ldapssl_client_init() [0|1]
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param starttls Start TLS using STARTTLS parameter [0|1]
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @tip Once a connection is found and returned, a lock will be acquired to
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * lock that particular connection, so that another thread does not try and
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * use this connection while it is busy. Once you are finished with a connection,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * apr_ldap_connection_close() must be called to release this connection.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @deffunc util_ldap_connection_t *util_ldap_connection_find(request_rec *r, const char *host, int port,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * const char *binddn, const char *bindpw, deref_options deref,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * int netscapessl, int starttls)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholesutil_ldap_connection_t *util_ldap_connection_find(request_rec *r, const char *host, int port,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes const char *binddn, const char *bindpw, deref_options deref,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int netscapessl, int starttls);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/**
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * Compare two DNs for sameness
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param r The request record
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param ldc The LDAP connection being used.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param url The URL of the LDAP connection - used for deciding which cache to use.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param dn The first DN to compare.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param reqdn The DN to compare the first DN to.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param compare_dn_on_server Flag to determine whether the DNs should be checked using
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * LDAP calls or with a direct string comparision. A direct
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * string comparison is faster, but not as accurate - false
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * negative comparisons are possible.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @tip Two DNs can be equal and still fail a string comparison. Eg "dc=example,dc=com"
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * and "dc=example, dc=com". Use the compare_dn_on_server unless there are serious
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * performance issues.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @deffunc int util_ldap_cache_comparedn(request_rec *r, util_ldap_connection_t *ldc,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * const char *url, const char *dn, const char *reqdn,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * int compare_dn_on_server)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholesint util_ldap_cache_comparedn(request_rec *r, util_ldap_connection_t *ldc,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes const char *url, const char *dn, const char *reqdn,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes int compare_dn_on_server);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/**
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * A generic LDAP compare function
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param r The request record
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param ldc The LDAP connection being used.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param url The URL of the LDAP connection - used for deciding which cache to use.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param dn The DN of the object in which we do the compare.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param attrib The attribute within the object we are comparing for.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param value The value of the attribute we are trying to compare for.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @tip Use this function to determine whether an attribute/value pair exists within an
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * object. Typically this would be used to determine LDAP group membership.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @deffunc int util_ldap_cache_compare(request_rec *r, util_ldap_connection_t *ldc,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * const char *url, const char *dn, const char *attrib, const char *value)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholesint util_ldap_cache_compare(request_rec *r, util_ldap_connection_t *ldc,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes const char *url, const char *dn, const char *attrib, const char *value);
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/**
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * Checks a username/password combination by binding to the LDAP server
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param r The request record
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param ldc The LDAP connection being used.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param url The URL of the LDAP connection - used for deciding which cache to use.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param basedn The Base DN to search for the user in.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param scope LDAP scope of the search.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param attrs LDAP attributes to return in search.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param filter The user to search for in the form of an LDAP filter. This filter must return
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * exactly one user for the check to be successful.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param bindpw The user password to bind as.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param binddn The DN of the user will be returned in this variable.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param retvals The values corresponding to the attributes requested in the attrs array.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @tip The filter supplied will be searched for. If a single entry is returned, an attempt
54d22ed1c429b903b029bbd62621f11a9e286137minfrin * is made to bind as that user. If this bind succeeds, the user is not validated.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @deffunc int util_ldap_cache_checkuserid(request_rec *r, util_ldap_connection_t *ldc,
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * char *url, const char *basedn, int scope, char **attrs,
54d22ed1c429b903b029bbd62621f11a9e286137minfrin * char *filter, char *bindpw, char **binddn, char ***retvals)
54d22ed1c429b903b029bbd62621f11a9e286137minfrin */
54d22ed1c429b903b029bbd62621f11a9e286137minfrinint util_ldap_cache_checkuserid(request_rec *r, util_ldap_connection_t *ldc,
54d22ed1c429b903b029bbd62621f11a9e286137minfrin const char *url, const char *basedn, int scope, char **attrs,
54d22ed1c429b903b029bbd62621f11a9e286137minfrin const char *filter, const char *bindpw, const char **binddn, const char ***retvals);
54d22ed1c429b903b029bbd62621f11a9e286137minfrin
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/* from apr_ldap_cache.c */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/**
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * Init the LDAP cache
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param pool The pool to use to initialise the cache
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param reqsize The size of the shared memory segement to request. A size
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * of zero requests the max size possible from
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * apr_shmem_init()
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @deffunc void util_ldap_cache_init(apr_pool_t *p)
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @return The status code returned is the status code of the
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * apr_smmem_init() call. Regardless of the status, the cache
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * will be set up at least for in-process or in-thread operation.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes */
54d22ed1c429b903b029bbd62621f11a9e286137minfrinapr_status_t util_ldap_cache_init(apr_pool_t *pool, apr_size_t reqsize);
81965264d92dd8c9ca21d058420f6f6da34b3032minfrin
81965264d92dd8c9ca21d058420f6f6da34b3032minfrin/**
81965264d92dd8c9ca21d058420f6f6da34b3032minfrin * Display formatted stats for cache
81965264d92dd8c9ca21d058420f6f6da34b3032minfrin * @param The pool to allocate the returned string from
54d22ed1c429b903b029bbd62621f11a9e286137minfrin * @tip This function returns a string allocated from the provided pool that describes
54d22ed1c429b903b029bbd62621f11a9e286137minfrin * various stats about the cache.
54d22ed1c429b903b029bbd62621f11a9e286137minfrin * @deffunc char *util_ald_cache_display(apr_pool_t *pool)
54d22ed1c429b903b029bbd62621f11a9e286137minfrin */
81965264d92dd8c9ca21d058420f6f6da34b3032minfrinchar *util_ald_cache_display(apr_pool_t *pool);
54d22ed1c429b903b029bbd62621f11a9e286137minfrin
e18ba90a1e610b43062e90cfa8bf0c1edcad7a49bnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/* from apr_ldap_cache_mgr.c */
560fd0658902ab57754616c172d8953e69fc4722bnicholes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes/**
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * Display formatted stats for cache
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @param The pool to allocate the returned string from
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @tip This function returns a string allocated from the provided pool that describes
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * various stats about the cache.
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholes * @deffunc char *util_ald_cache_display(apr_pool_t *pool)
54d22ed1c429b903b029bbd62621f11a9e286137minfrin */
d5b12fe8ae917e654a33247fd4e59dc9e75170aebnicholeschar *util_ald_cache_display(apr_pool_t *pool);
54d22ed1c429b903b029bbd62621f11a9e286137minfrin
54d22ed1c429b903b029bbd62621f11a9e286137minfrin#endif /* APU_HAS_LDAP */
54d22ed1c429b903b029bbd62621f11a9e286137minfrin#endif /* UTIL_LDAP_H */
54d22ed1c429b903b029bbd62621f11a9e286137minfrin