src/server/daemon/ldap_resource.h

Sat, 18 Mar 2023 11:05:40 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 18 Mar 2023 11:05:40 +0100
changeset 474
eb7640c59e9b
parent 464
0a29110b94ec
permissions
-rw-r--r--

fix broken log_ereport call

/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright 2023 Olaf Wintermann. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   1. Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *
 *   2. Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef LDAP_RESOURCE_H
#define LDAP_RESOURCE_H

#include "resourcepool.h"

#include <ldap.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifndef LDAP_PORT
#define LDAP_PORT 389
#endif
#ifndef LDAPS_PORT
#define LDAPS_PORT 636
#endif
    
typedef struct LDAPResourcePool {
    /*
     * ResourcePool parameters
     */
    pblock *param;
    
    /*
     * Cfg memorypool
     */
    pool_handle_t *pool;
    
    /*
     * ResourcePool name
     */
    const char *name;
    
    /*
     * ldap uri
     */
    char *ldap_uri;
    
    /*
     * ldap host
     * 
     * only used when no ldap_uri is specified
     */
    char *host;
    
    /*
     * ldap port
     */
    int port;
    
    /*
     * admin binddn
     */
    char *binddn;
    
    /*
     * admin bindpw
     */
    char *bindpw;
    
    /*
     * bind every LDAP session to binddn
     */
    WSBool bind;
    
    
} LDAPResourcePool;

typedef struct LDAPResource {
    LDAP *ldap;
    LDAPResourcePool *res_pool;
} LDAPResource;

ResourceType* ldap_get_resource_type(void);

    
LDAP* ws_ldap_resource_create_connection(
        const char *hostname,
        int port,
        int ssl,
        int ldap_version);

LDAP* ws_ldap_resource_create_uri_connection(
        const char *uri,
        int ldap_version);

void ws_ldap_close(LDAP *ldap);


/* resource pool implementation functions */
void * ldap_resourcepool_init(pool_handle_t *pool, const char *rpname, pblock *pb);
void   ldap_resourcepool_destroy(LDAPResourcePool *pool);
void * ldap_resourcepool_createresource(LDAPResourcePool *respool);
void   ldap_resourcepool_freeresource(LDAPResourcePool *pool, LDAPResource *res);
int    ldap_resourcepool_prepare(LDAPResourcePool *pool, LDAPResource *res);
int    ldap_resourcepool_finish(LDAPResourcePool *pool, LDAPResource *res);
void * ldap_resourcepool_getresourcedata(LDAPResource *res);


int ldap_resource_bind(LDAPResourcePool *respool, LDAP *ldap, struct berval **server_cred);

int ws_ldap_bind(LDAP *ldap, const char *binddn, const char *bindpw, struct berval **server_cred);



#ifdef __cplusplus
}
#endif

#endif /* LDAP_RESOURCE_H */

mercurial