2 * Copyright 1999, Dmitry Kovalev <mit@openldap.org>, All rights reserved.
4 * Redistribution and use in source and binary forms are permitted only
5 * as authorized by the OpenLDAP Public License. A copy of this
6 * license is available at http://www.OpenLDAP.org/license.html or
7 * in file LICENSE in the top-level directory of the distribution.
16 #include <sys/types.h>
30 backsql_info *si = (backsql_info *)be->be_private;
32 Debug( LDAP_DEBUG_TRACE, "==>backsql_db_config()\n", 0, 0, 0 );
35 if ( !strcasecmp( argv[ 0 ], "dbhost" ) ) {
37 Debug( LDAP_DEBUG_TRACE,
38 "<==backsql_db_config (%s line %d): "
39 "missing hostname in \"dbhost\" directive\n",
43 si->dbhost = ch_strdup( argv[ 1 ] );
44 Debug( LDAP_DEBUG_TRACE,
45 "<==backsql_db_config(): hostname=%s\n",
48 } else if ( !strcasecmp( argv[ 0 ], "dbuser" ) ) {
50 Debug( LDAP_DEBUG_TRACE,
51 "<==backsql_db_config (%s line %d): "
52 "missing username in \"dbuser\" directive\n",
56 si->dbuser = ch_strdup( argv[ 1 ] );
57 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): dbuser=%s\n",
60 } else if ( !strcasecmp( argv[ 0 ], "dbpasswd" ) ) {
62 Debug( LDAP_DEBUG_TRACE,
63 "<==backsql_db_config (%s line %d): "
64 "missing password in \"dbpasswd\" directive\n",
68 si->dbpasswd = ch_strdup( argv[ 1 ] );
69 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
70 "dbpasswd=%s\n", /* si->dbpasswd */ "xxxx", 0, 0 );
72 } else if ( !strcasecmp( argv[ 0 ], "dbname" ) ) {
74 Debug( LDAP_DEBUG_TRACE,
75 "<==backsql_db_config (%s line %d): "
76 "missing database name in \"dbname\" "
77 "directive\n", fname, lineno, 0 );
80 si->dbname = ch_strdup( argv[ 1 ] );
81 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): dbname=%s\n",
84 } else if ( !strcasecmp( argv[ 0 ], "concat_pattern" ) ) {
86 Debug( LDAP_DEBUG_TRACE,
87 "<==backsql_db_config (%s line %d): "
89 "in \"concat_pattern\" directive\n",
93 if ( backsql_split_pattern( argv[ 1 ], &si->concat_func, 2 ) ) {
94 Debug( LDAP_DEBUG_TRACE,
95 "<==backsql_db_config (%s line %d): "
96 "unable to parse pattern \"%s\"\n"
97 "in \"concat_pattern\" directive\n",
98 fname, lineno, argv[ 1 ] );
101 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
102 "concat_pattern=\"%s\"\n", argv[ 1 ], 0, 0 );
104 } else if ( !strcasecmp( argv[ 0 ], "subtree_cond" ) ) {
106 Debug( LDAP_DEBUG_TRACE,
107 "<==backsql_db_config (%s line %d): "
108 "missing SQL condition "
109 "in \"subtree_cond\" directive\n",
113 ber_str2bv( argv[ 1 ], 0, 1, &si->subtree_cond );
114 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
115 "subtree_cond=%s\n", si->subtree_cond.bv_val, 0, 0 );
117 } else if ( !strcasecmp( argv[ 0 ], "children_cond" ) ) {
119 Debug( LDAP_DEBUG_TRACE,
120 "<==backsql_db_config (%s line %d): "
121 "missing SQL condition "
122 "in \"children_cond\" directive\n",
126 ber_str2bv( argv[ 1 ], 0, 1, &si->children_cond );
127 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
128 "subtree_cond=%s\n", si->children_cond.bv_val, 0, 0 );
130 } else if ( !strcasecmp( argv[ 0 ], "oc_query" ) ) {
132 Debug( LDAP_DEBUG_TRACE,
133 "<==backsql_db_config (%s line %d): "
134 "missing SQL statement "
135 "in \"oc_query\" directive\n",
139 si->oc_query = ch_strdup( argv[ 1 ] );
140 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
141 "oc_query=%s\n", si->oc_query, 0, 0 );
143 } else if ( !strcasecmp( argv[ 0 ], "at_query" ) ) {
145 Debug( LDAP_DEBUG_TRACE,
146 "<==backsql_db_config (%s line %d): "
147 "missing SQL statement "
148 "in \"at_query\" directive\n",
152 si->at_query = ch_strdup( argv[ 1 ] );
153 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
154 "at_query=%s\n", si->at_query, 0, 0 );
156 } else if ( !strcasecmp( argv[ 0 ], "insentry_query" ) ) {
158 Debug( LDAP_DEBUG_TRACE,
159 "<==backsql_db_config (%s line %d): "
160 "missing SQL statement "
161 "in \"insentry_query\" directive\n",
165 si->insentry_query = ch_strdup( argv[ 1 ] );
166 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
167 "insentry_query=%s\n", si->insentry_query, 0, 0 );
169 } else if ( !strcasecmp( argv[ 0 ], "create_needs_select" ) ) {
171 Debug( LDAP_DEBUG_TRACE,
172 "<==backsql_db_config (%s line %d): "
173 "missing { yes | no }"
174 "in \"create_needs_select\" directive\n",
179 if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) {
180 si->bsql_flags |= BSQLF_CREATE_NEEDS_SELECT;
182 } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) {
183 si->bsql_flags &= ~BSQLF_CREATE_NEEDS_SELECT;
186 Debug( LDAP_DEBUG_TRACE,
187 "<==backsql_db_config (%s line %d): "
188 "\"create_needs_select\" directive arg "
189 "must be \"yes\" or \"no\"\n",
194 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
195 "create_needs_select =%s\n",
196 BACKSQL_CREATE_NEEDS_SELECT( si ) ? "yes" : "no",
199 } else if ( !strcasecmp( argv[ 0 ], "upper_func" ) ) {
201 Debug( LDAP_DEBUG_TRACE,
202 "<==backsql_db_config (%s line %d): "
203 "missing function name "
204 "in \"upper_func\" directive\n",
208 ber_str2bv( argv[ 1 ], 0, 1, &si->upper_func );
209 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
210 "upper_func=%s\n", si->upper_func.bv_val, 0, 0 );
212 } else if ( !strcasecmp( argv[ 0 ], "upper_needs_cast" ) ) {
214 Debug( LDAP_DEBUG_TRACE,
215 "<==backsql_db_config (%s line %d): "
216 "missing { yes | no }"
217 "in \"upper_needs_cast\" directive\n",
222 if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) {
223 si->bsql_flags |= BSQLF_UPPER_NEEDS_CAST;
225 } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) {
226 si->bsql_flags &= ~BSQLF_UPPER_NEEDS_CAST;
229 Debug( LDAP_DEBUG_TRACE,
230 "<==backsql_db_config (%s line %d): "
231 "\"upper_needs_cast\" directive arg "
232 "must be \"yes\" or \"no\"\n",
237 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
238 "upper_needs_cast =%s\n",
239 BACKSQL_UPPER_NEEDS_CAST( si ) ? "yes" : "no", 0, 0 );
241 } else if ( !strcasecmp( argv[ 0 ], "strcast_func" ) ) {
243 Debug( LDAP_DEBUG_TRACE,
244 "<==backsql_db_config (%s line %d): "
245 "missing function name "
246 "in \"strcast_func\" directive\n",
250 ber_str2bv( argv[ 1 ], 0, 1, &si->strcast_func );
251 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
252 "strcast_func=%s\n", si->strcast_func.bv_val, 0, 0 );
254 } else if ( !strcasecmp( argv[ 0 ], "delentry_query" ) ) {
256 Debug( LDAP_DEBUG_TRACE,
257 "<==backsql_db_config (%s line %d): "
258 "missing SQL statement "
259 "in \"delentry_query\" directive\n",
263 si->delentry_query = ch_strdup( argv[ 1 ] );
264 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
265 "delentry_query=%s\n", si->delentry_query, 0, 0 );
267 } else if ( !strcasecmp( argv[ 0 ], "has_ldapinfo_dn_ru") ) {
269 Debug( LDAP_DEBUG_TRACE,
270 "<==backsql_db_config (%s line %d): "
271 "missing { yes | no }"
272 "in \"has_ldapinfo_dn_ru\" directive\n",
277 if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) {
278 si->bsql_flags |= BSQLF_HAS_LDAPINFO_DN_RU;
279 si->bsql_flags |= BSQLF_DONTCHECK_LDAPINFO_DN_RU;
281 } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) {
282 si->bsql_flags &= ~BSQLF_HAS_LDAPINFO_DN_RU;
283 si->bsql_flags |= BSQLF_DONTCHECK_LDAPINFO_DN_RU;
286 Debug( LDAP_DEBUG_TRACE,
287 "<==backsql_db_config (%s line %d): "
288 "\"has_ldapinfo_dn_ru\" directive arg "
289 "must be \"yes\" or \"no\"\n",
294 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
295 "has_ldapinfo_dn_ru=%s\n",
296 BACKSQL_HAS_LDAPINFO_DN_RU( si ) ? "yes" : "no", 0, 0 );
298 } else if ( !strcasecmp( argv[ 0 ], "fail_if_no_mapping") ) {
300 Debug( LDAP_DEBUG_TRACE,
301 "<==backsql_db_config (%s line %d): "
302 "missing { yes | no }"
303 "in \"fail_if_no_mapping\" directive\n",
308 if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) {
309 si->bsql_flags |= BSQLF_FAIL_IF_NO_MAPPING;
311 } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) {
312 si->bsql_flags &= ~BSQLF_FAIL_IF_NO_MAPPING;
315 Debug( LDAP_DEBUG_TRACE,
316 "<==backsql_db_config (%s line %d): "
317 "\"fail_if_no_mapping\" directive arg "
318 "must be \"yes\" or \"no\"\n",
323 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
324 "fail_if_no_mapping=%s\n",
325 BACKSQL_FAIL_IF_NO_MAPPING( si ) ? "yes" : "no", 0, 0 );
328 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): "
329 "unknown directive \"%s\" (ignored)\n",
330 fname, lineno, argv[ 0 ] );
336 #endif /* SLAPD_SQL */