Apache HTTPD
apr_ldap_init.c
Go to the documentation of this file.
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * apr_ldap_init.c: LDAP v2/v3 common initialise
19 *
20 * Original code from auth_ldap module for Apache v1.3:
21 * Copyright 1998, 1999 Enbridge Pipelines Inc.
22 * Copyright 1999-2001 Dave Carrigan
23 */
24
25#include "apr.h"
26#include "apu.h"
27#include "apu_config.h"
28
29#if APU_DSO_BUILD
30#define APU_DSO_LDAP_BUILD
31#endif
32
33#include "apr_ldap.h"
34#include "apu_internal.h"
35#include "apr_errno.h"
36#include "apr_pools.h"
37#include "apr_strings.h"
38
39#if APR_HAS_LDAP
40
60 const char *cert_auth_file,
63{
64
67
68#if APR_HAS_LDAP_SSL /* compiled with ssl support */
69
70 /* Novell */
71#if APR_HAS_NOVELL_LDAPSDK
73#endif
74
75 /* if a certificate was specified, set it */
76 if (cert_auth_file) {
78 cert->type = cert_file_type;
79 cert->path = cert_auth_file;
81 }
82
83#else /* not compiled with SSL Support */
84 if (cert_auth_file) {
85 result->reason = "LDAP: Attempt to set certificate store failed. "
86 "Not built with SSL support";
87 result->rc = -1;
88 }
89#endif /* APR_HAS_LDAP_SSL */
90
91 if (result->rc != -1) {
92 result->msg = ldap_err2string(result->rc);
93 }
94
95 if (LDAP_SUCCESS != result->rc) {
96 return APR_EGENERAL;
97 }
98
99 return APR_SUCCESS;
100
101}
102
103
117{
118
119#if APR_HAS_LDAP_SSL && APR_HAS_LDAPSSL_CLIENT_DEINIT
121#endif
122 return APR_SUCCESS;
123
124}
125
126
148 LDAP **ldap,
149 const char *hostname,
150 int portno,
151 int secure,
153{
154
157
158#if APR_HAS_LDAPSSL_INIT
159#if APR_HAS_SOLARIS_LDAPSDK
160 /*
161 * Using the secure argument should aways be possible. But as LDAP SDKs
162 * tend to have different quirks and bugs, this needs to be tested for
163 * for each of them, first. For Solaris LDAP it works, and the method
164 * with ldap_set_option doesn't.
165 */
167#else
169#endif
170#elif APR_HAS_LDAP_SSLINIT
171 *ldap = ldap_sslinit((char *)hostname, portno, 0);
172#else
173 *ldap = ldap_init((char *)hostname, portno);
174#endif
175
176 if (*ldap != NULL) {
177#if APR_HAS_SOLARIS_LDAPSDK
178 if (secure == APR_LDAP_SSL)
179 return APR_SUCCESS;
180 else
181#endif
183 }
184 else {
185 /* handle the error case */
188
189 result->reason = "APR LDAP: Unable to initialize the LDAP connection";
190 result->rc = -1;
191 return APR_EGENERAL;
192 }
193
194}
195
196
205{
208
209 result->reason = "APR LDAP: Built with "
211 " LDAP SDK";
212 return APR_SUCCESS;
213
214}
215
216#if APU_DSO_BUILD
217
218/* For DSO builds, export the table of entry points into the apr_ldap DSO
219 * See include/private/apu_internal.h for the corresponding declarations
220 */
231};
232
233#endif /* APU_DSO_BUILD */
234
235#endif /* APR_HAS_LDAP */
APR Error Codes.
APR memory allocation.
APR Strings library.
const char * hostname
#define APR_EGENERAL
Definition apr_errno.h:313
apr_size_t size
const char int apr_pool_t * pool
Definition apr_cstr.h:84
#define APR_SUCCESS
Definition apr_errno.h:225
apr_array_header_t ** result
#define apr_pcalloc(p, size)
Definition apr_pools.h:465
return NULL
Definition mod_so.c:359