]> git.sur5r.net Git - openldap/blob - doc/man/man5/slapd-sql.5
complete access checking documentation
[openldap] / doc / man / man5 / slapd-sql.5
1 .TH SLAPD-SQL 5 "RELEASEDATE" "OpenLDAP LDVERSION"
2 .\" $OpenLDAP$
3 .SH NAME
4 slapd-sql \- SQL backend to slapd
5 .SH SYNOPSIS
6 ETCDIR/slapd.conf
7 .SH DESCRIPTION
8 The primary purpose of this
9 .BR slapd (8)
10 backend is to PRESENT information stored in some RDBMS as an LDAP subtree
11 without any programming (some SQL and maybe stored procedures can't be
12 considered programming, anyway ;).
13 .LP
14 That is, for example, when you (some ISP) have account information you
15 use in an RDBMS, and want to use modern solutions that expect such
16 information in LDAP (to authenticate users, make email lookups etc.).
17 Or you want to synchronize or distribute information between different
18 sites/applications that use RDBMSes and/or LDAP.
19 Or whatever else...
20 .LP
21 It is NOT designed as a general-purpose backend that uses RDBMS instead
22 of BerkeleyDB (as the standard BDB backend does), though it can be
23 used as such with several limitations.
24 You can take a look at
25 .B http://www.openldap.org/faq/index.cgi?file=378 
26 (OpenLDAP FAQ-O-Matic/General LDAP FAQ/Directories vs. conventional
27 databases) to find out more on this point.
28 .LP
29 The idea (detailed below) is to use some metainformation to translate
30 LDAP queries to SQL queries, leaving relational schema untouched, so
31 that old applications can continue using it without any
32 modifications.
33 This allows SQL and LDAP applications to inter-operate without
34 replication, and exchange data as needed.
35 .LP
36 The SQL backend is designed to be tunable to virtually any relational
37 schema without having to change source (through that metainformation
38 mentioned).
39 Also, it uses ODBC to connect to RDBMSes, and is highly configurable
40 for SQL dialects RDBMSes may use, so it may be used for integration
41 and distribution of data on different RDBMSes, OSes, hosts etc., in
42 other words, in highly heterogeneous environment.
43 .LP
44 This backend is \fIexperimental\fP.
45 .SH CONFIGURATION
46 These
47 .B slapd.conf
48 options apply to the SQL backend database, which means that 
49 they must follow a "database sql" line and come before any
50 subsequent "backend" or "database" lines.
51 Other database options not specific to this backend are described 
52 in the
53 .BR slapd.conf (5)
54 manual page.
55 .SH DATA SOURCE CONFIGURATION
56
57 .TP
58 .B dbname <datasource name>
59 The name of the ODBC datasource to use.
60 .LP
61 .B dbhost <hostname>
62 .br
63 .B dbpasswd <password>
64 .br
65 .B dbuser <username>
66 .RS
67 The three above options are generally unneeded, because this information
68 is taken from the datasource specified by the
69 .B dbname
70 directive.
71 They allow to override datasource settings.
72 Also, several RDBMS' drivers tend to require explicit passing of user/password,
73 even if those are given in datasource (Note:
74 .B dbhost
75 is currently ignored).
76 .RE
77 .SH SCOPING CONFIGURATION
78 These options specify SQL query templates for scoping searches.
79
80 .TP
81 .B subtree_cond <SQL expression>
82 Specifies a where-clause template used to form a subtree search condition
83 (dn="(.+,)?<dn>$").
84 It may differ from one SQL dialect to another (see samples).
85 By default, it is constructed based on the knowledge about
86 how to normalize DN values (e.g.
87 \fB"<upper_func>(ldap_entries.dn) LIKE CONCAT('%',?)"\fP);
88 see \fBupper_func\fP, \fBupper_needs_cast\fP, \fBconcat_pattern\fP
89 and \fBstrcast_func\fP in "HELPER CONFIGURATION" for details.
90
91 .TP
92 .B children_cond <SQL expression>
93 Specifies a where-clause template used to form a children search condition
94 (dn=".+,<dn>$").
95 It may differ from one SQL dialect to another (see samples).
96 By default, it is constructed based on the knowledge about
97 how to normalize DN values (e.g.
98 \fB"<upper_func>(ldap_entries.dn) LIKE CONCAT('%,',?)"\fP);
99 see \fBupper_func\fP, \fBupper_needs_cast\fP, \fBconcat_pattern\fP
100 and \fBstrcast_func\fP in "HELPER CONFIGURATION" for details.
101
102 .TP
103 .B use_subtree_shortcut { NO | yes }
104 Do not use the subtree condition when the searchBase is the database
105 suffix, and the scope is subtree; rather collect all entries.
106
107 .RE
108 .SH STAMEMENT CONFIGURATION
109 These options specify SQL query templates for loading schema mapping
110 metainformation, adding and deleting entries to ldap_entries, etc.
111 All these and subtree_cond should have the given default values.
112 For the current value it is recommended to look at the sources,
113 or in the log output when slapd starts with "-d 5" or greater.
114 Note that the parameter number and order must not be changed.
115
116 .TP
117 .B oc_query <SQL expression>
118 The query that is used to collect the objectClass mapping data
119 from table \fIldap_oc_mappings\fP; see "METAINFORMATION USED" for details.
120 The default is
121 \fB"SELECT id, name, keytbl, keycol, create_proc, delete_proc, expect_return
122 FROM ldap_oc_mappings"\fP.
123
124 .TP
125 .B at_query <SQL expression>
126 The query that is used to collect the attributeType mapping data
127 from table \fIldap_attr_mappings\fP; see "METAINFORMATION USED" for details.
128 The default is
129 \fB"SELECT name, sel_expr, from_tbls, join_where, add_proc, delete_proc,
130 param_order, expect_return FROM ldap_attr_mappings WHERE oc_map_id=?"\fP.
131
132 .TP
133 .B id_query <SQL expression>
134 The query that is used to map a DN to an entry
135 in table \fIldap_entries\fP; see "METAINFORMATION USED" for details.
136 The default is
137 \fB"SELECT id,keyval,oc_map_id,dn FROM ldap_entries WHERE <DN match expr>"\fP,
138 where \fB<DN match expr>\fP is constructed based on the knowledge about
139 how to normalize DN values (e.g. \fB"dn=?"\fP if no means to uppercase
140 strings are available; typically, \fB"<upper_func>(dn)=?"\fP is used);
141 see \fBupper_func\fP, \fBupper_needs_cast\fP, \fBconcat_pattern\fP
142 and \fBstrcast_func\fP in "HELPER CONFIGURATION" for details.
143
144 .TP
145 .B insentry_stmt <SQL expression>
146 The statement that is used to insert a new entry
147 in table \fIldap_entries\fP; see "METAINFORMATION USED" for details.
148 The default is
149 \fB"INSERT INTO ldap_entries (dn, oc_map_id, parent, keyval) VALUES
150 (?, ?, ?, ?)"\fP.
151
152 .TP
153 .B delentry_stmt <SQL expression>
154 The statement that is used to delete an existing entry
155 from table \fIldap_entries\fP; see "METAINFORMATION USED" for details.
156 The default is
157 \fB"DELETE FROM ldap_entries WHERE id=?"\fP.
158
159 .TP
160 .B delobjclasses_stmt <SQL expression>
161 The statement that is used to delete an existing entry's ID
162 from table \fIldap_objclasses\fP; see "METAINFORMATION USED" for details.
163 The default is
164 \fB""DELETE FROM ldap_entry_objclasses WHERE entry_id=?"\fP.
165
166 .RE
167 .SH HELPER CONFIGURATION
168 These statements are used to modify the default behavior of the backend
169 according to issues of the dialect of the RDBMS.
170 The first options essentially refer to string and DN normalization
171 when building filters.
172 LDAP normalization is more than upper- (or lower-)casing everything;
173 however, as a reasonable trade-off, for case-sensitive RDBMSes the backend
174 can be instructed to uppercase strings and DNs by providing
175 the \fBupper_func\fP directive.
176 Some RDBMSes, to use functions on arbitrary data types, e.g. string
177 constants, requires a cast, which is triggered
178 by the \fBupper_needs_cast\fP directive.
179 If required, a string cast function can be provided as well,
180 by using the \fBstrcast_func\fP directive.
181 Finally, a custom string concatenation pattern may be required;
182 it is provided by the \fBconcat_pattern\fP directive.
183
184 .TP
185 .B upper_func <SQL function name>
186 Specifies the name of a function that converts a given value to uppercase.
187 This is used for case insensitive matching when the RDBMS is case sensitive.
188 It may differ from one SQL dialect to another (e.g. \fBUCASE\fP, \fBUPPER\fP
189 or whatever; see samples).  By default, none is used, i.e. strings are not
190 uppercased, so matches may be case sensitive.
191
192 .TP
193 .B upper_needs_cast { NO | yes }
194 Set this directive to 
195 .B yes
196 if 
197 .B upper_func
198 needs an explicit cast when applied to literal strings.
199 A cast in the form
200 .B CAST (<arg> AS VARCHAR(<max DN length>))
201 is used, where
202 .B <max DN length>
203 is builtin in back-sql; see macro
204 .B BACKSQL_MAX_DN_LEN
205 (currently 255; note that slapd's builtin limit, in macro
206 .BR SLAP_LDAPDN_MAXLEN ,
207 is set to 8192).
208 This is \fIexperimental\fP and may change in future releases.
209
210 .TP
211 .TP
212 .B strcast_func <SQL function name>
213 Specifies the name of a function that converts a given value to a string
214 for appropriate ordering.  This is used in "SELECT DISTINCT" statements
215 for strongly typed RDBMSes with little implicit casting (like PostgreSQL),
216 when a literal string is specified.
217 This is \fIexperimental\fP and may change in future releases.
218
219 .B concat_pattern <pattern>
220 This statement defines the
221 .B pattern 
222 that is used to concatenate strings.  The
223 .B pattern
224 MUST contain two question marks, '?', that will be replaced 
225 by the two strings that must be concatenated.  The default value is
226 .BR "CONCAT(?,?)";
227 a form that is known to be highly portable (IBM db2, PostgreSQL) is 
228 .BR "?||?",
229 but an explicit cast may be required when operating on literal strings:
230 .BR "CAST(?||? AS VARCHAR(<length>))".
231 On some RDBMSes (IBM db2, MSSQL) the form
232 .B "?+?"
233 is known to work as well.
234 Carefully check the documentation of your RDBMS or stay with the examples
235 for supported ones.
236 This is \fIexperimental\fP and may change in future releases.
237
238 .TP
239 .B has_ldapinfo_dn_ru { NO | yes }
240 Explicitly inform the backend whether the dn_ru column
241 (DN in reverse uppercased form) is present in table \fIldap_entries\fP.
242 Overrides automatic check (this is required, ofr instance,
243 by PostgreSQL/unixODBC).
244 This is \fIexperimental\fP and may change in future releases.
245
246 .TP
247 .B fail_if_no_mapping { NO | yes }
248 When set to
249 .B yes
250 it forces \fIattribute\fP write operations to fail if no appropriate
251 mapping between LDAP attributes and SQL data is available.
252 The default behavior is to ignore those changes that cannot be mapped.
253 It has no impact on objectClass mapping, i.e. if the
254 .I structuralObjectClass
255 of an entry cannot be mapped to SQL by looking up its name 
256 in ldap_oc_mappings, an 
257 .I add
258 operation will fail regardless of the
259 .B fail_if_no_mapping
260 switch; see section "METAINFORMATION USED" for details.
261 This is \fIexperimental\fP and may change in future releases.
262
263 .TP
264 .B allow_orphans { NO | yes }
265 When set to 
266 .B yes
267 orphaned entries (i.e. without the parent entry in the database)
268 can be added.  This option should be used with care, possibly 
269 in conjunction with some special rule on the RDBMS side that
270 dynamically creates the missing parent.
271
272 .TP
273 .B baseObject [ <filename> ]
274 Instructs the database to create and manage an in-memory baseObject
275 entry instead of looking for one in the RDBMS.
276 If the (optional) 
277 .B <filename>
278 argument is given, the entry is read from that file in
279 .BR LDIF (5)
280 format; otherwise, an entry with objectClass \fBextensibleObject\fP
281 is created based on the contents of the RDN of the \fIbaseObject\fP.
282 This is particularly useful when \fIldap_entries\fP
283 information is stored in a view rather than in a table, and 
284 .B union
285 is not supported for views, so that the view can only specify
286 one rule to compute the entry structure for one objectClass.
287 This topic is discussed further in section "METAINFORMATION USED".
288 This is \fIexperimental\fP and may change in future releases.
289
290 .TP
291 .B create_needs_select { NO | yes }
292 Instructs the database whether or not entry creation
293 in table \fIldap_entries\fP needs a subsequent select to collect 
294 the automatically assigned ID, instead of being returned 
295 by a stored procedure.
296
297 .LP
298 .B fetch_attrs <attrlist>
299 .br
300 .B fetch_all_attrs { NO | yes }
301 .RS
302 The first statement allows to provide a list of attributes that
303 must always be fetched in addition to those requested by any specific
304 operation, because they are required for the proper usage of the
305 backend.  For instance, all attributes used in ACLs should be listed
306 here.  The second statement is a shortcut to require all attributes 
307 to be always loaded.  Note that the dynamically generated attributes,
308 e.g. \fIhasSubordinates\fP, \fIentryDN\fP and other implementation
309 dependent attributes are \fBNOT\fP generated at this point, for
310 consistency with the rest of slapd.  This may change in the future.
311 .RE
312
313 .TP
314 .B sqllayer <name> [...]
315 Loads the layer \fB<name>\fP onto a stack of helpers that are used 
316 to map DNs from LDAP to SQL representation and vice-versa.
317 Subsequent args are passed to the layer configuration routine.
318 This is \fIhighly experimental\fP and should be used with extreme care.
319 The API of the layers is not frozen yet, so it is unpublished.
320
321 .SH METAINFORMATION USED
322 .LP
323 Almost everything mentioned later is illustrated in examples located
324 in the
325 .B servers/slapd/back-sql/rdbms_depend/
326 directory in the OpenLDAP source tree, and contains scripts for
327 generating sample database for Oracle, MS SQL Server, mySQL and more
328 (including PostgreSQL and IBM db2).
329 .LP
330 The first thing that one must arrange is what set of LDAP
331 object classes can present your RDBMS information.
332 .LP
333 The easiest way is to create an objectClass for each entity you had in
334 ER-diagram when designing your relational schema.
335 Any relational schema, no matter how normalized it is, was designed
336 after some model of your application's domain (for instance, accounts,
337 services etc. in ISP), and is used in terms of its entities, not just
338 tables of normalized schema.
339 It means that for every attribute of every such instance there is an
340 effective SQL query that loads its values.
341 .LP
342 Also you might want your object classes to conform to some of the standard
343 schemas like inetOrgPerson etc.
344 .LP
345 Nevertheless, when you think it out, we must define a way to translate
346 LDAP operation requests to (a series of) SQL queries.
347 Let us deal with the SEARCH operation.
348 .LP
349 Example:
350 Let's suppose that we store information about persons working in our 
351 organization in two tables:
352 .LP
353 .nf
354   PERSONS              PHONES
355   ----------           -------------
356   id integer           id integer
357   first_name varchar   pers_id integer references persons(id)
358   last_name varchar    phone
359   middle_name varchar
360   ...
361 .fi
362 .LP
363 (PHONES contains telephone numbers associated with persons).
364 A person can have several numbers, then PHONES contains several
365 records with corresponding pers_id, or no numbers (and no records in
366 PHONES with such pers_id).
367 An LDAP objectclass to present such information could look like this:
368 .LP
369 .nf
370   person
371   -------
372   MUST cn
373   MAY telephoneNumber $ firstName $ lastName
374   ...
375 .fi
376 .LP
377 To fetch all values for cn attribute given person ID, we construct the
378 query:
379 .LP
380 .nf
381   SELECT CONCAT(persons.first_name,' ',persons.last_name)
382       AS cn FROM persons WHERE persons.id=?
383 .fi
384 .LP
385 for telephoneNumber we can use:
386 .LP
387 .nf
388   SELECT phones.phone AS telephoneNumber FROM persons,phones
389       WHERE persons.id=phones.pers_id AND persons.id=?
390 .fi
391 .LP
392 If we wanted to service LDAP requests with filters like
393 (telephoneNumber=123*), we would construct something like:
394 .LP
395 .nf
396   SELECT ... FROM persons,phones
397       WHERE persons.id=phones.pers_id
398           AND persons.id=?
399           AND phones.phone like '%1%2%3%'
400 .fi
401 .LP
402 (note how the telephoneNumber match is expanded in multiple wildcards
403 to account for interspersed ininfluential chars like spaces, dashes
404 and so; this occurs by design because telephoneNumber is defined after 
405 a specially recognized syntax).
406 So, if we had information about what tables contain values for each
407 attribute, how to join these tables and arrange these values, we could
408 try to automatically generate such statements, and translate search
409 filters to SQL WHERE clauses.
410 .LP
411 To store such information, we add three more tables to our schema
412 and fill it with data (see samples):
413 .LP
414 .nf
415   ldap_oc_mappings (some columns are not listed for clarity)
416   ---------------
417   id=1
418   name="person"
419   keytbl="persons"
420   keycol="id"
421 .fi
422 .LP
423 This table defines a mapping between objectclass (its name held in the
424 "name" column), and a table that holds the primary key for corresponding
425 entities.
426 For instance, in our example, the person entity, which we are trying
427 to present as "person" objectclass, resides in two tables (persons and
428 phones), and is identified by the persons.id column (that we will call
429 the primary key for this entity).
430 Keytbl and keycol thus contain "persons" (name of the table), and "id"
431 (name of the column).
432 .LP
433 .nf
434   ldap_attr_mappings (some columns are not listed for clarity)
435   -----------
436   id=1
437   oc_map_id=1
438   name="cn"
439   sel_expr="CONCAT(persons.first_name,' ',persons.last_name)"
440   from_tbls="persons"
441   join_where=NULL
442   ************
443   id=<n>
444   oc_map_id=1
445   name="telephoneNumber"
446   sel_expr="phones.phone"
447   from_tbls="persons,phones"
448   join_where="phones.pers_id=persons.id"
449 .fi
450 .LP
451 This table defines mappings between LDAP attributes and SQL queries
452 that load their values.
453 Note that, unlike LDAP schema, these are not
454 .B attribute types
455 - the attribute "cn" for "person" objectclass can
456 have its values in different tables than "cn" for some other objectclass,
457 so attribute mappings depend on objectclass mappings (unlike attribute
458 types in LDAP schema, which are indifferent to objectclasses).
459 Thus, we have oc_map_id column with link to oc_mappings table.
460 .LP
461 Now we cut the SQL query that loads values for a given attribute into 3 parts.
462 First goes into sel_expr column - this is the expression we had
463 between SELECT and FROM keywords, which defines WHAT to load.
464 Next is table list - text between FROM and WHERE keywords.
465 It may contain aliases for convenience (see examples).
466 The last is part of the where clause, which (if it exists at all) expresses the
467 condition for joining the table containing values with the table
468 containing the primary key (foreign key equality and such).
469 If values are in the same table as the primary key, then this column is
470 left NULL (as for cn attribute above).
471 .LP
472 Having this information in parts, we are able to not only construct
473 queries that load attribute values by id of entry (for this we could
474 store SQL query as a whole), but to construct queries that load id's
475 of objects that correspond to a given search filter (or at least part of
476 it).
477 See below for examples.
478 .LP
479 .nf
480   ldap_entries
481   ------------
482   id=1
483   dn=<dn you choose>
484   oc_map_id=...
485   parent=<parent record id>
486   keyval=<value of primary key>
487 .fi
488 .LP
489 This table defines mappings between DNs of entries in your LDAP tree,
490 and values of primary keys for corresponding relational data.
491 It has recursive structure (parent column references id column of the
492 same table), which allows you to add any tree structure(s) to your
493 flat relational data.
494 Having id of objectclass mapping, we can determine table and column
495 for primary key, and keyval stores value of it, thus defining the exact
496 tuple corresponding to the LDAP entry with this DN.
497 .LP
498 Note that such design (see exact SQL table creation query) implies one
499 important constraint - the key must be an integer.
500 But all that I know about well-designed schemas makes me think that it's
501 not very narrow ;) If anyone needs support for different types for
502 keys - he may want to write a patch, and submit it to OpenLDAP ITS,
503 then I'll include it.
504 .LP
505 Also, several people complained that they don't really need very
506 structured trees, and they don't want to update one more table every
507 time they add or delete an instance in the relational schema.
508 Those people can use a view instead of a real table for ldap_entries, something
509 like this (by Robin Elfrink):
510 .LP
511 .nf
512   CREATE VIEW ldap_entries (id, dn, oc_map_id, parent, keyval)
513       AS
514           SELECT 0, UPPER('o=MyCompany,c=NL'),
515               3, 0, 'baseObject' FROM unixusers WHERE userid='root'
516       UNION
517           SELECT (1000000000+userid),
518               UPPER(CONCAT(CONCAT('cn=',gecos),',o=MyCompany,c=NL')),
519               1, 0, userid FROM unixusers
520       UNION
521           SELECT (2000000000+groupnummer),
522               UPPER(CONCAT(CONCAT('cn=',groupnaam),',o=MyCompany,c=NL')),
523               2, 0, groupnummer FROM groups;
524 .fi
525
526 .LP
527 If your RDBMS does not support
528 .B unions
529 in views, only one objectClass can be mapped in
530 .BR ldap_entries ,
531 and the baseObject cannot be created; in this case, see the 
532 .B baseObject
533 directive for a possible workaround.
534
535 .LP
536 .SH Typical SQL backend operation
537 Having metainformation loaded, the SQL backend uses these tables to
538 determine a set of primary keys of candidates (depending on search
539 scope and filter).
540 It tries to do it for each objectclass registered in ldap_objclasses.
541 .LP
542 Example:
543 for our query with filter (telephoneNumber=123*) we would get the following 
544 query generated (which loads candidate IDs)
545 .LP
546 .nf
547   SELECT ldap_entries.id,persons.id, 'person' AS objectClass,
548          ldap_entries.dn AS dn
549     FROM ldap_entries,persons,phones
550    WHERE persons.id=ldap_entries.keyval
551      AND ldap_entries.objclass=?
552      AND ldap_entries.parent=?
553      AND phones.pers_id=persons.id
554      AND (phones.phone LIKE '%1%2%3%')
555 .fi
556 .LP
557 (for ONELEVEL search)
558 or "... AND dn=?" (for BASE search)
559 or "... AND dn LIKE '%?'" (for SUBTREE)
560 .LP
561 Then, for each candidate, we load the requested attributes using
562 per-attribute queries like
563 .LP
564 .nf
565   SELECT phones.phone AS telephoneNumber
566     FROM persons,phones
567    WHERE persons.id=? AND phones.pers_id=persons.id
568 .fi
569 .LP
570 Then, we use test_filter() from the frontend API to test the entry for a full
571 LDAP search filter match (since we cannot effectively make sense of
572 SYNTAX of corresponding LDAP schema attribute, we translate the filter
573 into the most relaxed SQL condition to filter candidates), and send it to
574 the user.
575 .LP
576 ADD, DELETE, MODIFY and MODRDN operations are also performed on per-attribute
577 metainformation (add_proc etc.).
578 In those fields one can specify an SQL statement or stored procedure
579 call which can add, or delete given values of a given attribute, using
580 the given entry keyval (see examples -- mostly PostgreSQL, ORACLE and MSSQL 
581 - since as of this writing there are no stored procs in MySQL).
582 .LP
583 We just add more columns to ldap_oc_mappings and ldap_attr_mappings, holding
584 statements to execute (like create_proc, add_proc, del_proc etc.), and
585 flags governing the order of parameters passed to those statements.
586 Please see samples to find out what are the parameters passed, and other
587 information on this matter - they are self-explanatory for those familiar
588 with the concepts expressed above.
589 .LP
590 .SH Common techniques (referrals, multiclassing etc.)
591 First of all, let's remember that among other major differences to the
592 complete LDAP data model, the concept above does not directly support
593 such things as multiple objectclasses per entry, and referrals.
594 Fortunately, they are easy to adopt in this scheme.
595 The SQL backend suggests one more table being added to the schema:
596 ldap_entry_objectclasses(entry_id,oc_name).
597 .LP
598 The first contains any number of objectclass names that corresponding
599 entries will be found by, in addition to that mentioned in
600 mapping.
601 The SQL backend automatically adds attribute mapping for the "objectclass"
602 attribute to each objectclass mapping that loads values from this table.
603 So, you may, for instance, have a mapping for inetOrgPerson, and use it
604 for queries for "person" objectclass...
605 .LP
606 Referrals used to be implemented in a loose manner by adding an extra
607 table that allowed any entry to host a "ref" attribute, along with
608 a "referral" extra objectClass in table ldap_entry_objclasses.
609 In the current implementation, referrals are treated like any other
610 user-defined schema, since "referral" is a structural objectclass.
611 The suggested practice is to define a "referral" entry in ldap_oc_mappings,
612 holding a naming attribute, e.g. "ou" or "cn", a "ref" attribute,
613 containing the url; in case multiple referrals per entry are needed,
614 a separate table for urls can be created, where urls are mapped
615 to the respective entries.
616 The use of the naming attribute usually requires to add 
617 an "extensibleObject" value to ldap_entry_objclasses.
618
619 .LP
620 .SH Caveats
621 As previously stated, this backend should not be considered
622 a replacement of other data storage backends, but rather a gateway
623 to existing RDBMS storages that need to be published in LDAP form.
624 .LP
625 The \fBhasSubordintes\fP operational attribute is honored by back-sql
626 in search results and in compare operations; it is partially honored
627 also in filtering.  Owing to design limitations, a (braindead?) filter
628 of the form
629 \fB(!(hasSubordinates=TRUE))\fP
630 will give no results instead of returning all the leaf entries, because
631 it actually expands into \fB... AND NOT (1=1)\fP.
632 If you need to find all the leaf entries, please use
633 \fB(hasSubordinates=FALSE)\fP
634 instead.
635 .LP
636 A directoryString value of the form "__First___Last_"
637 (where underscores should be replaced by spaces) corresponds
638 to its prettified counterpart "First_Last"; this is not currently
639 honored by back-sql if non-prettified data is written via RDBMS;
640 when non-prettified data is written thru back-sql, the prettified 
641 values are actually used instead.
642 .LP
643 .SH PROXY CACHE OVERLAY
644 The proxy cache overlay 
645 allows caching of LDAP search requests (queries) in a local database.
646 See 
647 .BR slapo-pcache (5)
648 for details.
649 .SH EXAMPLES
650 There are example SQL modules in the slapd/back-sql/rdbms_depend/
651 directory in the OpenLDAP source tree.
652 .SH ACCESS CONTROL
653 The 
654 .B sql
655 backend honors access control semantics as indicated in
656 .BR slapd.access (5)
657 (including the 
658 .B disclose
659 access privilege when enabled at compile time).
660 .SH FILES
661
662 .TP
663 ETCDIR/slapd.conf
664 default slapd configuration file
665 .SH SEE ALSO
666 .BR slapd.conf (5),
667 .BR slapd (8).