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