2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1999-2003 The OpenLDAP Foundation.
5 * Portions Copyright 1999 Dmitry Kovalev.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
17 * This work was initially developed by Dmitry Kovalev for inclusion
18 * by OpenLDAP Software.
26 #include "ac/string.h"
27 #include <sys/types.h>
41 backsql_info *si = (backsql_info *)be->be_private;
43 Debug( LDAP_DEBUG_TRACE, "==>backsql_db_config()\n", 0, 0, 0 );
46 if ( !strcasecmp( argv[ 0 ], "dbhost" ) ) {
48 Debug( LDAP_DEBUG_TRACE,
49 "<==backsql_db_config (%s line %d): "
50 "missing hostname in \"dbhost\" directive\n",
54 si->dbhost = ch_strdup( argv[ 1 ] );
55 Debug( LDAP_DEBUG_TRACE,
56 "<==backsql_db_config(): hostname=%s\n",
59 } else if ( !strcasecmp( argv[ 0 ], "dbuser" ) ) {
61 Debug( LDAP_DEBUG_TRACE,
62 "<==backsql_db_config (%s line %d): "
63 "missing username in \"dbuser\" directive\n",
67 si->dbuser = ch_strdup( argv[ 1 ] );
68 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): dbuser=%s\n",
71 } else if ( !strcasecmp( argv[ 0 ], "dbpasswd" ) ) {
73 Debug( LDAP_DEBUG_TRACE,
74 "<==backsql_db_config (%s line %d): "
75 "missing password in \"dbpasswd\" directive\n",
79 si->dbpasswd = ch_strdup( argv[ 1 ] );
80 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
81 "dbpasswd=%s\n", /* si->dbpasswd */ "xxxx", 0, 0 );
83 } else if ( !strcasecmp( argv[ 0 ], "dbname" ) ) {
85 Debug( LDAP_DEBUG_TRACE,
86 "<==backsql_db_config (%s line %d): "
87 "missing database name in \"dbname\" "
88 "directive\n", fname, lineno, 0 );
91 si->dbname = ch_strdup( argv[ 1 ] );
92 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): dbname=%s\n",
95 } else if ( !strcasecmp( argv[ 0 ], "concat_pattern" ) ) {
97 Debug( LDAP_DEBUG_TRACE,
98 "<==backsql_db_config (%s line %d): "
100 "in \"concat_pattern\" directive\n",
104 if ( backsql_split_pattern( argv[ 1 ], &si->concat_func, 2 ) ) {
105 Debug( LDAP_DEBUG_TRACE,
106 "<==backsql_db_config (%s line %d): "
107 "unable to parse pattern \"%s\"\n"
108 "in \"concat_pattern\" directive\n",
109 fname, lineno, argv[ 1 ] );
112 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
113 "concat_pattern=\"%s\"\n", argv[ 1 ], 0, 0 );
115 } else if ( !strcasecmp( argv[ 0 ], "subtree_cond" ) ) {
117 Debug( LDAP_DEBUG_TRACE,
118 "<==backsql_db_config (%s line %d): "
119 "missing SQL condition "
120 "in \"subtree_cond\" directive\n",
124 ber_str2bv( argv[ 1 ], 0, 1, &si->subtree_cond );
125 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
126 "subtree_cond=%s\n", si->subtree_cond.bv_val, 0, 0 );
128 } else if ( !strcasecmp( argv[ 0 ], "children_cond" ) ) {
130 Debug( LDAP_DEBUG_TRACE,
131 "<==backsql_db_config (%s line %d): "
132 "missing SQL condition "
133 "in \"children_cond\" directive\n",
137 ber_str2bv( argv[ 1 ], 0, 1, &si->children_cond );
138 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
139 "subtree_cond=%s\n", si->children_cond.bv_val, 0, 0 );
141 } else if ( !strcasecmp( argv[ 0 ], "oc_query" ) ) {
143 Debug( LDAP_DEBUG_TRACE,
144 "<==backsql_db_config (%s line %d): "
145 "missing SQL statement "
146 "in \"oc_query\" directive\n",
150 si->oc_query = ch_strdup( argv[ 1 ] );
151 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
152 "oc_query=%s\n", si->oc_query, 0, 0 );
154 } else if ( !strcasecmp( argv[ 0 ], "at_query" ) ) {
156 Debug( LDAP_DEBUG_TRACE,
157 "<==backsql_db_config (%s line %d): "
158 "missing SQL statement "
159 "in \"at_query\" directive\n",
163 si->at_query = ch_strdup( argv[ 1 ] );
164 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
165 "at_query=%s\n", si->at_query, 0, 0 );
167 } else if ( !strcasecmp( argv[ 0 ], "insentry_query" ) ) {
169 Debug( LDAP_DEBUG_TRACE,
170 "<==backsql_db_config (%s line %d): "
171 "missing SQL statement "
172 "in \"insentry_query\" directive\n",
176 si->insentry_query = ch_strdup( argv[ 1 ] );
177 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
178 "insentry_query=%s\n", si->insentry_query, 0, 0 );
180 } else if ( !strcasecmp( argv[ 0 ], "create_needs_select" ) ) {
182 Debug( LDAP_DEBUG_TRACE,
183 "<==backsql_db_config (%s line %d): "
184 "missing { yes | no }"
185 "in \"create_needs_select\" directive\n",
190 if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) {
191 si->bsql_flags |= BSQLF_CREATE_NEEDS_SELECT;
193 } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) {
194 si->bsql_flags &= ~BSQLF_CREATE_NEEDS_SELECT;
197 Debug( LDAP_DEBUG_TRACE,
198 "<==backsql_db_config (%s line %d): "
199 "\"create_needs_select\" directive arg "
200 "must be \"yes\" or \"no\"\n",
205 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
206 "create_needs_select =%s\n",
207 BACKSQL_CREATE_NEEDS_SELECT( si ) ? "yes" : "no",
210 } else if ( !strcasecmp( argv[ 0 ], "upper_func" ) ) {
212 Debug( LDAP_DEBUG_TRACE,
213 "<==backsql_db_config (%s line %d): "
214 "missing function name "
215 "in \"upper_func\" directive\n",
219 ber_str2bv( argv[ 1 ], 0, 1, &si->upper_func );
220 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
221 "upper_func=%s\n", si->upper_func.bv_val, 0, 0 );
223 } else if ( !strcasecmp( argv[ 0 ], "upper_needs_cast" ) ) {
225 Debug( LDAP_DEBUG_TRACE,
226 "<==backsql_db_config (%s line %d): "
227 "missing { yes | no }"
228 "in \"upper_needs_cast\" directive\n",
233 if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) {
234 si->bsql_flags |= BSQLF_UPPER_NEEDS_CAST;
236 } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) {
237 si->bsql_flags &= ~BSQLF_UPPER_NEEDS_CAST;
240 Debug( LDAP_DEBUG_TRACE,
241 "<==backsql_db_config (%s line %d): "
242 "\"upper_needs_cast\" directive arg "
243 "must be \"yes\" or \"no\"\n",
248 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
249 "upper_needs_cast =%s\n",
250 BACKSQL_UPPER_NEEDS_CAST( si ) ? "yes" : "no", 0, 0 );
252 } else if ( !strcasecmp( argv[ 0 ], "strcast_func" ) ) {
254 Debug( LDAP_DEBUG_TRACE,
255 "<==backsql_db_config (%s line %d): "
256 "missing function name "
257 "in \"strcast_func\" directive\n",
261 ber_str2bv( argv[ 1 ], 0, 1, &si->strcast_func );
262 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
263 "strcast_func=%s\n", si->strcast_func.bv_val, 0, 0 );
265 } else if ( !strcasecmp( argv[ 0 ], "delentry_query" ) ) {
267 Debug( LDAP_DEBUG_TRACE,
268 "<==backsql_db_config (%s line %d): "
269 "missing SQL statement "
270 "in \"delentry_query\" directive\n",
274 si->delentry_query = ch_strdup( argv[ 1 ] );
275 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
276 "delentry_query=%s\n", si->delentry_query, 0, 0 );
278 } else if ( !strcasecmp( argv[ 0 ], "has_ldapinfo_dn_ru") ) {
280 Debug( LDAP_DEBUG_TRACE,
281 "<==backsql_db_config (%s line %d): "
282 "missing { yes | no }"
283 "in \"has_ldapinfo_dn_ru\" directive\n",
288 if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) {
289 si->bsql_flags |= BSQLF_HAS_LDAPINFO_DN_RU;
290 si->bsql_flags |= BSQLF_DONTCHECK_LDAPINFO_DN_RU;
292 } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) {
293 si->bsql_flags &= ~BSQLF_HAS_LDAPINFO_DN_RU;
294 si->bsql_flags |= BSQLF_DONTCHECK_LDAPINFO_DN_RU;
297 Debug( LDAP_DEBUG_TRACE,
298 "<==backsql_db_config (%s line %d): "
299 "\"has_ldapinfo_dn_ru\" directive arg "
300 "must be \"yes\" or \"no\"\n",
305 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
306 "has_ldapinfo_dn_ru=%s\n",
307 BACKSQL_HAS_LDAPINFO_DN_RU( si ) ? "yes" : "no", 0, 0 );
309 } else if ( !strcasecmp( argv[ 0 ], "fail_if_no_mapping") ) {
311 Debug( LDAP_DEBUG_TRACE,
312 "<==backsql_db_config (%s line %d): "
313 "missing { yes | no }"
314 "in \"fail_if_no_mapping\" directive\n",
319 if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) {
320 si->bsql_flags |= BSQLF_FAIL_IF_NO_MAPPING;
322 } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) {
323 si->bsql_flags &= ~BSQLF_FAIL_IF_NO_MAPPING;
326 Debug( LDAP_DEBUG_TRACE,
327 "<==backsql_db_config (%s line %d): "
328 "\"fail_if_no_mapping\" directive arg "
329 "must be \"yes\" or \"no\"\n",
334 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
335 "fail_if_no_mapping=%s\n",
336 BACKSQL_FAIL_IF_NO_MAPPING( si ) ? "yes" : "no", 0, 0 );
339 return SLAP_CONF_UNKNOWN;
345 #endif /* SLAPD_SQL */