src/server/daemon/ldap_resource.h

changeset 461
9b20b8f3582b
child 462
72848970541a
equal deleted inserted replaced
460:b9a447b02046 461:9b20b8f3582b
1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 2023 Olaf Wintermann. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #ifndef LDAP_RESOURCE_H
30 #define LDAP_RESOURCE_H
31
32 #include "resourcepool.h"
33
34 #include <ldap.h>
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 #ifndef LDAP_PORT
41 #define LDAP_PORT 389
42 #endif
43 #ifndef LDAPS_PORT
44 #define LDAPS_PORT 636
45 #endif
46
47 typedef struct LDAPResourcePool {
48 /*
49 * ResourcePool parameters
50 */
51 pblock *param;
52
53 /*
54 * Cfg memorypool
55 */
56 pool_handle_t *pool;
57
58 /*
59 * ResourcePool name
60 */
61 const char *name;
62
63 /*
64 * ldap uri
65 */
66 char *ldap_uri;
67
68 /*
69 * ldap host
70 *
71 * only used when no ldap_uri is specified
72 */
73 char *host;
74
75 /*
76 * ldap port
77 */
78 int port;
79
80
81 } LDAPResourcePool;
82
83 typedef struct LDAPResource {
84 LDAP *ldap;
85 } LDAPResource;
86
87 ResourceType* ldap_get_resource_type(void);
88
89
90 LDAP* ws_ldap_resource_create_connection(
91 const char *hostname,
92 int port,
93 int ssl,
94 int ldap_version);
95
96 LDAP* ws_ldap_resource_create_uri_connection(
97 const char *uri,
98 int ldap_version);
99
100 void ws_ldap_close(LDAP *ldap);
101
102
103 /* resource pool implementation functions */
104 void * ldap_resourcepool_init(pool_handle_t *pool, const char *rpname, pblock *pb);
105 void ldap_resourcepool_destroy(LDAPResourcePool *pool);
106 void * ldap_resourcepool_createresource(LDAPResourcePool *respool);
107 void ldap_resourcepool_freeresource(LDAPResourcePool *pool, LDAPResource *res);
108 int ldap_resourcepool_prepare(LDAPResourcePool *pool, LDAPResource *res);
109 int ldap_resourcepool_finish(LDAPResourcePool *pool, LDAPResource *res);
110 void * ldap_resourcepool_getresourcedata(LDAPResource *res);
111
112
113
114 #ifdef __cplusplus
115 }
116 #endif
117
118 #endif /* LDAP_RESOURCE_H */
119

mercurial