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 ], "oc_query" ) ) {
119 Debug( LDAP_DEBUG_TRACE,
120 "<==backsql_db_config (%s line %d): "
121 "missing SQL statement "
122 "in \"oc_query\" directive\n",
126 si->oc_query = ch_strdup( argv[ 1 ] );
127 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
128 "oc_query=%s\n", si->oc_query, 0, 0 );
130 } else if ( !strcasecmp( argv[ 0 ], "at_query" ) ) {
132 Debug( LDAP_DEBUG_TRACE,
133 "<==backsql_db_config (%s line %d): "
134 "missing SQL statement "
135 "in \"at_query\" directive\n",
139 si->at_query = ch_strdup( argv[ 1 ] );
140 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
141 "at_query=%s\n", si->at_query, 0, 0 );
143 } else if ( !strcasecmp( argv[ 0 ], "insentry_query" ) ) {
145 Debug( LDAP_DEBUG_TRACE,
146 "<==backsql_db_config (%s line %d): "
147 "missing SQL statement "
148 "in \"insentry_query\" directive\n",
152 si->insentry_query = ch_strdup( argv[ 1 ] );
153 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
154 "insentry_query=%s\n", si->insentry_query, 0, 0 );
156 } else if ( !strcasecmp( argv[ 0 ], "create_needs_select" ) ) {
158 Debug( LDAP_DEBUG_TRACE,
159 "<==backsql_db_config (%s line %d): "
160 "missing { yes | no }"
161 "in \"create_needs_select\" directive\n",
166 if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) {
167 si->bsql_flags |= BSQLF_CREATE_NEEDS_SELECT;
169 } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) {
170 si->bsql_flags &= ~BSQLF_CREATE_NEEDS_SELECT;
173 Debug( LDAP_DEBUG_TRACE,
174 "<==backsql_db_config (%s line %d): "
175 "\"create_needs_select\" directive arg "
176 "must be \"yes\" or \"no\"\n",
181 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
182 "create_needs_select =%s\n",
183 BACKSQL_CREATE_NEEDS_SELECT( si ) ? "yes" : "no",
186 } else if ( !strcasecmp( argv[ 0 ], "upper_func" ) ) {
188 Debug( LDAP_DEBUG_TRACE,
189 "<==backsql_db_config (%s line %d): "
190 "missing function name "
191 "in \"upper_func\" directive\n",
195 ber_str2bv( argv[ 1 ], 0, 1, &si->upper_func );
196 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
197 "upper_func=%s\n", si->upper_func.bv_val, 0, 0 );
199 } else if ( !strcasecmp( argv[ 0 ], "upper_needs_cast" ) ) {
201 Debug( LDAP_DEBUG_TRACE,
202 "<==backsql_db_config (%s line %d): "
203 "missing { yes | no }"
204 "in \"upper_needs_cast\" directive\n",
209 if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) {
210 si->bsql_flags |= BSQLF_UPPER_NEEDS_CAST;
212 } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) {
213 si->bsql_flags &= ~BSQLF_UPPER_NEEDS_CAST;
216 Debug( LDAP_DEBUG_TRACE,
217 "<==backsql_db_config (%s line %d): "
218 "\"upper_needs_cast\" directive arg "
219 "must be \"yes\" or \"no\"\n",
224 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
225 "upper_needs_cast =%s\n",
226 BACKSQL_UPPER_NEEDS_CAST( si ) ? "yes" : "no", 0, 0 );
228 } else if ( !strcasecmp( argv[ 0 ], "strcast_func" ) ) {
230 Debug( LDAP_DEBUG_TRACE,
231 "<==backsql_db_config (%s line %d): "
232 "missing function name "
233 "in \"strcast_func\" directive\n",
237 ber_str2bv( argv[ 1 ], 0, 1, &si->strcast_func );
238 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
239 "strcast_func=%s\n", si->strcast_func.bv_val, 0, 0 );
241 } else if ( !strcasecmp( argv[ 0 ], "delentry_query" ) ) {
243 Debug( LDAP_DEBUG_TRACE,
244 "<==backsql_db_config (%s line %d): "
245 "missing SQL statement "
246 "in \"delentry_query\" directive\n",
250 si->delentry_query = ch_strdup( argv[ 1 ] );
251 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
252 "delentry_query=%s\n", si->delentry_query, 0, 0 );
254 } else if ( !strcasecmp( argv[ 0 ], "has_ldapinfo_dn_ru") ) {
256 Debug( LDAP_DEBUG_TRACE,
257 "<==backsql_db_config (%s line %d): "
258 "missing { yes | no }"
259 "in \"has_ldapinfo_dn_ru\" directive\n",
264 if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) {
265 si->bsql_flags |= BSQLF_HAS_LDAPINFO_DN_RU;
266 si->bsql_flags |= BSQLF_DONTCHECK_LDAPINFO_DN_RU;
268 } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) {
269 si->bsql_flags &= ~BSQLF_HAS_LDAPINFO_DN_RU;
270 si->bsql_flags |= BSQLF_DONTCHECK_LDAPINFO_DN_RU;
273 Debug( LDAP_DEBUG_TRACE,
274 "<==backsql_db_config (%s line %d): "
275 "\"has_ldapinfo_dn_ru\" directive arg "
276 "must be \"yes\" or \"no\"\n",
281 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
282 "has_ldapinfo_dn_ru=%s\n",
283 BACKSQL_HAS_LDAPINFO_DN_RU( si ) ? "yes" : "no", 0, 0 );
285 } else if ( !strcasecmp( argv[ 0 ], "fail_if_no_mapping") ) {
287 Debug( LDAP_DEBUG_TRACE,
288 "<==backsql_db_config (%s line %d): "
289 "missing { yes | no }"
290 "in \"fail_if_no_mapping\" directive\n",
295 if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) {
296 si->bsql_flags |= BSQLF_FAIL_IF_NO_MAPPING;
298 } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) {
299 si->bsql_flags &= ~BSQLF_FAIL_IF_NO_MAPPING;
302 Debug( LDAP_DEBUG_TRACE,
303 "<==backsql_db_config (%s line %d): "
304 "\"fail_if_no_mapping\" directive arg "
305 "must be \"yes\" or \"no\"\n",
310 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): "
311 "fail_if_no_mapping=%s\n",
312 BACKSQL_FAIL_IF_NO_MAPPING( si ) ? "yes" : "no", 0, 0 );
315 Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): "
316 "unknown directive \"%s\" (ignored)\n",
317 fname, lineno, argv[ 0 ] );
323 #endif /* SLAPD_SQL */