1# OpenLDAP: pkg/openldap-guide/admin/backends.sdf,v 1.8.2.7 2009/01/22 00:00:47 kurt Exp 2# Copyright 2007-2009 The OpenLDAP Foundation, All Rights Reserved. 3# COPYING RESTRICTIONS APPLY, see COPYRIGHT. 4 5H1: Backends 6 7 8H2: Berkeley DB Backends 9 10 11H3: Overview 12 13The {{bdb}} backend to {{slapd}}(8) is the recommended primary backend for a 14normal {{slapd}} database. It uses the Oracle Berkeley DB ({{TERM:BDB}}) 15package to store data. It makes extensive use of indexing and caching 16(see the {{SECT:Tuning}} section) to speed data access. 17 18{{hdb}} is a variant of the {{bdb}} backend that uses a hierarchical database 19layout which supports subtree renames. It is otherwise identical to the {{bdb}} 20 behavior, and all the same configuration options apply. 21 22Note: An {{hdb}} database needs a large {{idlcachesize}} for good search performance, 23typically three times the {{cachesize}} (entry cache size) or larger. 24 25H3: back-bdb/back-hdb Configuration 26 27MORE LATER 28 29H3: Further Information 30 31{{slapd-bdb}}(5) 32 33H2: LDAP 34 35 36H3: Overview 37 38The LDAP backend to {{slapd}}(8) is not an actual database; instead it acts 39as a proxy to forward incoming requests to another LDAP server. While 40processing requests it will also chase referrals, so that referrals are fully 41processed instead of being returned to the {{slapd}} client. 42 43Sessions that explicitly {{Bind}} to the {{back-ldap}} database always create 44their own private connection to the remote LDAP server. Anonymous sessions 45will share a single anonymous connection to the remote server. For sessions 46bound through other mechanisms, all sessions with the same DN will share the 47same connection. This connection pooling strategy can enhance the proxy's 48efficiency by reducing the overhead of repeatedly making/breaking multiple 49connections. 50 51The ldap database can also act as an information service, i.e. the identity 52of locally authenticated clients is asserted to the remote server, possibly 53in some modified form. For this purpose, the proxy binds to the remote server 54with some administrative identity, and, if required, authorizes the asserted 55identity. 56 57It is heavily used by a lot of other {{SECT: Backends}} and {{SECT: Overlays}}. 58 59H3: back-ldap Configuration 60 61As previously mentioned, {{slapd-ldap(5)}} is used behind the scenes by many 62other {{SECT: Backends}} and {{SECT: Overlays}}. Some of them merely provide a 63few configuration directive themselves, but have available to the administrator 64the whole of the {{slapd-ldap(5)}} options. 65 66For example, the {{SECT: Translucent Proxy}}, which retrieves entries from a 67remote LDAP server that can be partially overridden by the defined database, has 68only four specific {{translucent-}} directives, but can be configured using any 69of the normal {{slapd-ldap(5)}} options. See {[slapo-translucent(5)}} for details. 70 71Other {{SECT: Overlays}} allow you to tag directives in front of a normal 72{{slapd-ldap(5)}} directive. For example, the {{slapo-chain(5)}} overlay does 73this: 74 75{{"There are very few chain overlay specific directives; however, directives 76related to the instances of the ldap backend that may be implicitly instantiated 77by the overlay may assume a special meaning when used in conjunction with this 78overlay. They are described in slapd-ldap(5), and they also need to be prefixed 79by chain-."}} 80 81You may have also seen the {{slapd-ldap(5)}} backend used and described in the 82{{SECT: Push Based}} {{SECT: Replication}} section of the guide. 83 84It should therefore be obvious that the {{slapd-ldap(5)}} backend is extremely 85flexible and heavily used throughout the OpenLDAP Suite. 86 87The following is a very simple example, but already the power of the {{slapd-ldap(5)}} 88backend is seen by use of a {{uri list}}: 89 90> database ldap 91> suffix "dc=suretecsystems,dc=com" 92> rootdn "cn=slapd-ldap" 93> uri ldap://localhost/ ldap://remotehost ldap://remotehost2 94 95The URI list is space or comma-separated. Whenever the server that responds 96is not the first one in the list, the list is rearranged and the responsive 97server is moved to the head, so that it will be first contacted the next time 98a connection needs be created. 99 100This feature can be used to provide a form of load balancing when using 101{{SECT: MirrorMode replication}}. 102 103H3: Further Information 104 105{{slapd-ldap}}(5) 106 107H2: LDIF 108 109 110H3: Overview 111 112The LDIF backend to {{slapd}}(8) is a basic storage backend that stores 113entries in text files in LDIF format, and exploits the filesystem to create 114the tree structure of the database. It is intended as a cheap, low performance 115easy to use backend. 116 117When using the {{cn=config}} dynamic configuration database with persistent 118storage, the configuration data is stored using this backend. See {{slapd-config}}(5) 119for more information 120 121H3: back-ldif Configuration 122 123Like many other backends, the LDIF backend can be instantiated with very few 124configuration lines: 125 126> include ./schema/core.schema 127> 128> database ldif 129> directory "./ldif" 130> suffix "dc=suretecsystems,dc=com" 131> rootdn "cn=LDIF,dc=suretecsystems,dc=com" 132> rootpw LDIF 133 134You'll notice that when compared to examples below, there is no: 135 136> moduleload back_ldif.la 137 138directive. This is because {{back_ldif}} is always built in by default as it is 139used by {{slapd-config(5)}}, which again is built in by default. 140 141If we add the {{dcObject}} for {{dc=suretecsystems,dc=com}}, you can see how this 142is added behind the scenes on the file system: 143 144> dn: dc=suretecsystems,dc=com 145> objectClass: dcObject 146> objectClass: organization 147> dc: suretecsystems 148> o: Suretec Systems Ltd 149 150Now we add it to the directory: 151 152> ldapadd -x -H ldap://localhost:9011 -f suretec.ldif -D "cn=LDIF,dc=suretecsystems,dc=com" -w LDIF 153> adding new entry "dc=suretecsystems,dc=com" 154 155And inside {{F: ./ldif}} we have: 156 157> ls ./ldif 158> dc=suretecsystems,dc=com.ldif 159 160which again contains: 161 162> cat ldif/dc\=suretecsystems\,dc\=com.ldif 163> 164> dn: dc=suretecsystems 165> objectClass: dcObject 166> objectClass: organization 167> dc: suretecsystems 168> o: Suretec Systems Ltd. 169> structuralObjectClass: organization 170> entryUUID: 2134b714-e3a1-102c-9a15-f96ee263886d 171> creatorsName: cn=LDIF,dc=suretecsystems,dc=com 172> createTimestamp: 20080711142643Z 173> entryCSN: 20080711142643.661124Z#000000#000#000000 174> modifiersName: cn=LDIF,dc=suretecsystems,dc=com 175> modifyTimestamp: 20080711142643Z 176 177This is the complete format you would get when exporting your directory using 178{{F: slapcat}} etc. 179 180H3: Further Information 181 182{{slapd-ldif}}(5) 183 184H2: Metadirectory 185 186 187H3: Overview 188 189The meta backend to {{slapd}}(8) performs basic LDAP proxying with respect 190to a set of remote LDAP servers, called "targets". The information contained 191in these servers can be presented as belonging to a single Directory Information 192Tree ({{TERM:DIT}}). 193 194A basic knowledge of the functionality of the {{slapd-ldap}}(5) backend is 195recommended. This backend has been designed as an enhancement of the ldap 196backend. The two backends share many features (actually they also share portions 197 of code). While the ldap backend is intended to proxy operations directed 198 to a single server, the meta backend is mainly intended for proxying of 199 multiple servers and possibly naming context masquerading. 200 201These features, although useful in many scenarios, may result in excessive 202overhead for some applications, so its use should be carefully considered. 203 204 205H3: back-meta Configuration 206 207LATER 208 209H3: Further Information 210 211{{slapd-meta}}(5) 212 213H2: Monitor 214 215 216H3: Overview 217 218The monitor backend to {{slapd}}(8) is not an actual database; if enabled, 219it is automatically generated and dynamically maintained by slapd with 220information about the running status of the daemon. 221 222To inspect all monitor information, issue a subtree search with base {{cn=Monitor}}, 223requesting that attributes "+" and "*" are returned. The monitor backend produces 224mostly operational attributes, and LDAP only returns operational attributes 225that are explicitly requested. Requesting attribute "+" is an extension which 226requests all operational attributes. 227 228See the {{SECT:Monitoring}} section. 229 230H3: back-monitor Configuration 231 232The monitor database can be instantiated only once, i.e. only one occurrence 233of "database monitor" can occur in the {{slapd.conf(5)}} file. Also the suffix 234is automatically set to {{"cn=Monitor"}}. 235 236You can however set a {{rootdn}} and {{rootpw}}. The following is all that is 237needed to instantiate a monitor backend: 238 239> include ./schema/core.schema 240> 241> modulepath /usr/local/libexec/openldap 242> moduleload back_monitor.la 243> 244> database monitor 245> rootdn "cn=monitoring,cn=Monitor" 246> rootpw monitoring 247 248You can also apply Access Control to this database like any other database, for 249example: 250 251> access to dn.subtree="cn=Monitor" 252> by dn.exact="uid=Admin,dc=my,dc=org" write 253> by users read 254> by * none 255 256Note: The {{F: core.schema}} must be loaded for the monitor database to work. 257 258A small example of the data returned via {{ldapsearch}} would be: 259 260> ldapsearch -x -H ldap://localhost:9011 -b 'cn=Monitor' 261> # extended LDIF 262> # 263> # LDAPv3 264> # base <cn=Monitor> with scope subtree 265> # filter: (objectclass=*) 266> # requesting: ALL 267> # 268> 269> # Monitor 270> dn: cn=Monitor 271> objectClass: monitorServer 272> cn: Monitor 273> description: This subtree contains monitoring/managing objects. 274> description: This object contains information about this server. 275> description: Most of the information is held in operational attributes, which 276> must be explicitly requested. 277> 278> # Backends, Monitor 279> dn: cn=Backends,cn=Monitor 280> objectClass: monitorContainer 281> cn: Backends 282> description: This subsystem contains information about available backends. 283 284Please see the {{SECT: Monitoring}} section for complete examples of information 285available via this backend. 286 287H3: Further Information 288 289{{slapd-monitor}}(5) 290 291H2: Null 292 293 294H3: Overview 295 296The Null backend to {{slapd}}(8) is surely the most useful part of slapd: 297 298* Searches return success but no entries. 299* Compares return compareFalse. 300* Updates return success (unless readonly is on) but do nothing. 301* Binds other than as the rootdn fail unless the database option "bind on" is given. 302* The slapadd(8) and slapcat(8) tools are equally exciting. 303 304Inspired by the {{F:/dev/null}} device. 305 306H3: back-null Configuration 307 308This has to be one of the shortest configurations you'll ever do. In order to 309test this, your {{F: slapd.conf}} file would look like: 310 311> modulepath /usr/local/libexec/openldap 312> moduleload back_null.la 313 314> database null 315> suffix "cn=Nothing" 316> bind on 317 318The first two directives are only applicable if you've enabled module support and 319haven't "built-in" {{slapd-null(5)}} support (why would you?). 320 321{{bind on}} means: 322 323{{"Allow binds as any DN in this backend's suffix, with any password. The default is "off"."}} 324 325To test this backend with {{ldapsearch}}: 326 327> ldapsearch -x -H ldap://localhost:9011 -D "uid=none,cn=Nothing" -w testing -b 'cn=Nothing' 328> # extended LDIF 329> # 330> # LDAPv3 331> # base <cn=Nothing> with scope subtree 332> # filter: (objectclass=*) 333> # requesting: ALL 334> # 335> 336> # search result 337> search: 2 338> result: 0 Success 339> 340> # numResponses: 1 341 342 343H3: Further Information 344 345{{slapd-null}}(5) 346 347H2: Passwd 348 349 350H3: Overview 351 352The PASSWD backend to {{slapd}}(8) serves up the user account information 353listed in the system {{passwd}}(5) file (defaulting to {{F: /etc/passwd}}). 354 355This backend is provided for demonstration purposes only. The DN of each entry 356is "uid=<username>,<suffix>". 357 358H3: back-passwd Configuration 359 360The configuration using {{F: slapd.conf}} a slightly longer, but not much. For 361example: 362 363> include ./schema/core.schema 364> 365> modulepath /usr/local/libexec/openldap 366> moduleload back_passwd.la 367> 368> database passwd 369> suffix "cn=passwd" 370 371Again, testing this with {{ldapsearch}} would result in something like: 372 373> ldapsearch -x -H ldap://localhost:9011 -b 'cn=passwd' 374> # extended LDIF 375> # 376> # LDAPv3 377> # base <cn=passwd> with scope subtree 378> # filter: (objectclass=*) 379> # requesting: ALL 380> # 381> 382> # passwd 383> dn: cn=passwd 384> cn: passwd 385> objectClass: organizationalUnit 386> 387> # root, passwd 388> dn: uid=root,cn=passwd 389> objectClass: person 390> objectClass: uidObject 391> uid: root 392> cn: root 393> sn: root 394> description: root 395 396 397H3: Further Information 398 399{{slapd-passwd}}(5) 400 401H2: Perl/Shell 402 403H3: Overview 404 405The Perl backend to {{slapd}}(8) works by embedding a {{perl}}(1) interpreter 406into {{slapd}}(8). Any perl database section of the configuration file 407{{slapd.conf}}(5) must then specify what Perl module to use. Slapd then creates 408a new Perl object that handles all the requests for that particular instance of the backend. 409 410The Shell backend to {{slapd}}(8) executes external programs to implement 411operations, and is designed to make it easy to tie an existing database to the 412slapd front-end. This backend is is primarily intended to be used in prototypes. 413 414H3: back-perl/back-shell Configuration 415 416LATER 417 418H3: Further Information 419 420{{slapd-shell}}(5) and {{slapd-perl}}(5) 421 422H2: Relay 423 424 425H3: Overview 426 427The primary purpose of this {{slapd}}(8) backend is to map a naming context 428defined in a database running in the same {{slapd}}(8) instance into a 429virtual naming context, with attributeType and objectClass manipulation, if 430required. It requires the rwm overlay. 431 432This backend and the above mentioned overlay are experimental. 433 434H3: back-relay Configuration 435 436LATER 437 438H3: Further Information 439 440{{slapd-relay}}(5) 441 442H2: SQL 443 444 445H3: Overview 446 447The primary purpose of this {{slapd}}(8) backend is to PRESENT information 448stored in some RDBMS as an LDAP subtree without any programming (some SQL and 449maybe stored procedures can't be considered programming, anyway ;). 450 451That is, for example, when you (some ISP) have account information you use in 452an RDBMS, and want to use modern solutions that expect such information in LDAP 453(to authenticate users, make email lookups etc.). Or you want to synchronize or 454distribute information between different sites/applications that use RDBMSes 455and/or LDAP. Or whatever else... 456 457It is {{B:NOT}} designed as a general-purpose backend that uses RDBMS instead of 458BerkeleyDB (as the standard BDB backend does), though it can be used as such with 459several limitations. Please see {{SECT: LDAP vs RDBMS}} for discussion. 460 461The idea is to use some meta-information to translate LDAP queries to SQL queries, 462leaving relational schema untouched, so that old applications can continue using 463it without any modifications. This allows SQL and LDAP applications to interoperate 464without replication, and exchange data as needed. 465 466The SQL backend is designed to be tunable to virtually any relational schema without 467having to change source (through that meta-information mentioned). Also, it uses 468ODBC to connect to RDBMSes, and is highly configurable for SQL dialects RDBMSes 469may use, so it may be used for integration and distribution of data on different 470RDBMSes, OSes, hosts etc., in other words, in highly heterogeneous environments. 471 472This backend is experimental. 473 474H3: back-sql Configuration 475 476This backend has to be one of the most abused and complex backends there is. 477Therefore, we will go through a simple, small example that comes with the 478OpenLDAP source and can be found in {{F: servers/slapd/back-sql/rdbms_depend/README}} 479 480For this example we will be using PostgreSQL. 481 482First, we add to {{F: /etc/odbc.ini}} a block of the form: 483 484> [example] <=== 485> Description = Example for OpenLDAP's back-sql 486> Driver = PostgreSQL 487> Trace = No 488> Database = example <=== 489> Servername = localhost 490> UserName = manager <=== 491> Password = secret <=== 492> Port = 5432 493> ;Protocol = 6.4 494> ReadOnly = No 495> RowVersioning = No 496> ShowSystemTables = No 497> ShowOidColumn = No 498> FakeOidIndex = No 499> ConnSettings = 500 501The relevant information for our test setup is highlighted with '<===' on the 502right above. 503 504Next, we add to {{F: /etc/odbcinst.ini}} a block of the form: 505 506> [PostgreSQL] 507> Description = ODBC for PostgreSQL 508> Driver = /usr/lib/libodbcpsql.so 509> Setup = /usr/lib/libodbcpsqlS.so 510> FileUsage = 1 511 512 513We will presume you know how to create a database and user in PostgreSQL and 514how to set a password. Also, we'll presume you can populate the 'example' 515database you've just created with the following files, as found in {{F: servers/slapd/back-sql/rdbms_depend/pgsql }} 516 517> backsql_create.sql, testdb_create.sql, testdb_data.sql, testdb_metadata.sql 518 519Lastly, run the test: 520 521> [root@localhost]# cd $SOURCES/tests 522> [root@localhost]# SLAPD_USE_SQL=pgsql ./run sql-test000 523 524Briefly, you should see something like (cut short for space): 525 526> Cleaning up test run directory leftover from previous run. 527> Running ./scripts/sql-test000-read... 528> running defines.sh 529> Starting slapd on TCP/IP port 9011... 530> Testing SQL backend read operations... 531> Waiting 5 seconds for slapd to start... 532> Testing correct bind... dn:cn=Mitya Kovalev,dc=example,dc=com 533> Testing incorrect bind (should fail)... ldap_bind: Invalid credentials (49) 534> 535> ...... 536> 537> Filtering original ldif... 538> Comparing filter output... 539> >>>>> Test succeeded 540 541The test is basically readonly; this can be performed by all RDBMSes 542(listed above). 543 544There is another test, sql-test900-write, which is currently enabled 545only for PostgreSQL and IBM db2. 546 547Using {{F: sql-test000}}, files in {{F: servers/slapd/back-sql/rdbms_depend/pgsql/}} 548and the man page, you should be set. 549 550Note: This backend is experimental. 551 552H3: Further Information 553 554{{slapd-sql}}(5) and {{F: servers/slapd/back-sql/rdbms_depend/README}} 555