1# OpenLDAP: pkg/openldap-guide/admin/slapdconf2.sdf,v 1.20.2.21 2010/04/13 20:22:35 kurt Exp 2# Copyright 2005-2010 The OpenLDAP Foundation, All Rights Reserved. 3# COPYING RESTRICTIONS APPLY, see COPYRIGHT. 4 5H1: Configuring slapd 6 7Once the software has been built and installed, you are ready 8to configure {{slapd}}(8) for use at your site. 9 10Unlike previous 11OpenLDAP releases, the slapd(8) runtime configuration in 2.3 (and later) 12is fully LDAP-enabled and can be managed using the standard LDAP 13operations with data in {{TERM:LDIF}}. The LDAP configuration engine 14allows all of slapd's configuration options to be changed on the fly, 15generally without requiring a server restart for the changes 16to take effect. 17 18The old style {{slapd.conf}}(5) file is still 19supported, but must be converted to the new {{slapd-config}}(5) format 20to allow runtime changes to be saved. While the old style 21configuration uses a single file, normally installed as 22{{F:/usr/local/etc/openldap/slapd.conf}}, the new style 23uses a slapd backend database to store the configuration. The 24configuration database normally resides in the 25{{F:/usr/local/etc/openldap/slapd.d}} directory. An alternate configuration 26directory (or file) can be specified via a command-line option to 27{{slapd}}(8). 28 29This chapter briefly discusses converting to the new style configuration, 30then describes the general format of the configuration system, followed by 31a detailed description of commonly used config settings. 32 33Note: some of the backends and of the distributed overlays 34do not support runtime configuration yet. In those cases, 35the old style {{slapd.conf}}(5) file must be used. 36 37 38H2: Configuration Layout 39 40The slapd configuration is stored as a special LDAP directory with 41a predefined schema and DIT. There are specific objectClasses used to 42carry global configuration options, schema definitions, backend and 43database definitions, and assorted other items. A sample config tree 44is shown in Figure 5.1. 45 46!import "config_dit.png"; align="center"; title="Sample configuration tree" 47FT[align="Center"] Figure 5.1: Sample configuration tree. 48 49Other objects may be part of the configuration but were omitted from 50the illustration for clarity. 51 52The {{slapd-config}} configuration tree has a very specific structure. The 53root of the tree is named {{EX:cn=config}} and contains global configuration 54settings. Additional settings are contained in separate child entries: 55* Dynamically loaded modules 56.. These may only be used if the {{EX:--enable-modules}} option was 57used to configure the software. 58* Schema definitions 59.. The {{EX:cn=schema,cn=config}} entry contains the system schema (all 60the schema that is hard-coded in slapd). 61.. Child entries of {{EX:cn=schema,cn=config}} contain user schema as 62loaded from config files or added at runtime. 63* Backend-specific configuration 64* Database-specific configuration 65.. Overlays are defined in children of the Database entry. 66.. Databases and Overlays may also have other miscellaneous children. 67 68The usual rules for LDIF files apply to the configuration information: 69Comment lines beginning with a '{{EX:#}}' character 70are ignored. If a line begins with a single space, it is considered a 71continuation of the previous line (even if the previous line is a 72comment) and the single leading space is removed. Entries are separated by blank lines. 73 74The general layout of the config LDIF is as follows: 75 76> # global configuration settings 77> dn: cn=config 78> objectClass: olcGlobal 79> cn: config 80> <global config settings> 81> 82> # schema definitions 83> dn: cn=schema,cn=config 84> objectClass: olcSchemaConfig 85> cn: schema 86> <system schema> 87> 88> dn: cn={X}core,cn=schema,cn=config 89> objectClass: olcSchemaConfig 90> cn: {X}core 91> <core schema> 92> 93> # additional user-specified schema 94> ... 95> 96> # backend definitions 97> dn: olcBackend=<typeA>,cn=config 98> objectClass: olcBackendConfig 99> olcBackend: <typeA> 100> <backend-specific settings> 101> 102> # database definitions 103> dn: olcDatabase={X}<typeA>,cn=config 104> objectClass: olcDatabaseConfig 105> olcDatabase: {X}<typeA> 106> <database-specific settings> 107> 108> # subsequent definitions and settings 109> ... 110 111Some of the entries listed above have a numeric index {{EX:"{X}"}} in 112their names. While most configuration settings have an inherent ordering 113dependency (i.e., one setting must take effect before a subsequent one 114may be set), LDAP databases are inherently unordered. The numeric index 115is used to enforce a consistent ordering in the configuration database, 116so that all ordering dependencies are preserved. In most cases the index 117does not have to be provided; it will be automatically generated based 118on the order in which entries are created. 119 120Configuration directives are specified as values of individual 121attributes. 122Most of the attributes and objectClasses used in the slapd 123configuration have a prefix of {{EX:"olc"}} (OpenLDAP Configuration) 124in their names. Generally there is a one-to-one correspondence 125between the attributes and the old-style {{EX:slapd.conf}} configuration 126keywords, using the keyword as the attribute name, with the "olc" 127prefix attached. 128 129A configuration directive may take arguments. If so, the arguments are 130separated by whitespace. If an argument contains whitespace, 131the argument should be enclosed in double quotes {{EX:"like this"}}. 132In the descriptions that follow, arguments that should be replaced 133by actual text are shown in brackets {{EX:<>}}. 134 135The distribution contains an example configuration file that will 136be installed in the {{F: /usr/local/etc/openldap}} directory. 137A number of files containing schema definitions (attribute types 138and object classes) are also provided in the 139{{F: /usr/local/etc/openldap/schema}} directory. 140 141 142H2: Configuration Directives 143 144This section details commonly used configuration directives. For 145a complete list, see the {{slapd-config}}(5) manual page. This section 146will treat the configuration directives in a top-down order, starting 147with the global directives in the {{EX:cn=config}} entry. Each 148directive will be described along with its default value (if any) and 149an example of its use. 150 151 152H3: cn=config 153 154Directives contained in this entry generally apply to the server as a whole. 155Most of them are system or connection oriented, not database related. This 156entry must have the {{EX:olcGlobal}} objectClass. 157 158 159H4: olcIdleTimeout: <integer> 160 161Specify the number of seconds to wait before forcibly closing 162an idle client connection. A value of 0, the default, 163disables this feature. 164 165 166H4: olcLogLevel: <level> 167 168This directive specifies the level at which debugging statements 169and operation statistics should be syslogged (currently logged to 170the {{syslogd}}(8) {{EX:LOG_LOCAL4}} facility). You must have 171configured OpenLDAP {{EX:--enable-debug}} (the default) for this 172to work (except for the two statistics levels, which are always 173enabled). Log levels may be specified as integers or by keyword. 174Multiple log levels may be used and the levels are additive. 175To display what levels 176correspond to what kind of debugging, invoke slapd with {{EX:-d?}} 177or consult the table below. The possible values for <level> are: 178 179!block table; colaligns="RL"; align=Center; \ 180 title="Table 5.1: Debugging Levels" 181Level Keyword Description 182-1 any enable all debugging 1830 no debugging 1841 (0x1 trace) trace function callss 1852 (0x2 packets) debug packet handling 1864 (0x4 args) heavy trace debugging 1878 (0x8 conns) connection management 18816 (0x10 BER) print out packets sent and received 18932 (0x20 filter) search filter processing 19064 (0x40 config) configuration processing 191128 (0x80 ACL) access control list processing 192256 (0x100 stats) stats log connections/operations/results 193512 (0x200 stats2) stats log entries sent 1941024 (0x400 shell) print communication with shell backends 1952048 (0x800 parse) print entry parsing debugging 19616384 (0x4000 sync) syncrepl consumer processing 19732768 (0x8000 none) only messages that get logged whatever log level is set 198!endblock 199 200The desired log level can be input as a single integer that 201combines the (ORed) desired levels, both in decimal or in hexadecimal 202notation, as a list of integers (that are ORed internally), or as a list of the names that are shown between brackets, such that 203 204> olcLogLevel 129 205> olcLogLevel 0x81 206> olcLogLevel 128 1 207> olcLogLevel 0x80 0x1 208> olcLogLevel acl trace 209 210are equivalent. 211 212\Examples: 213 214E: olcLogLevel -1 215 216This will cause lots and lots of debugging information to be 217logged. 218 219E: olcLogLevel conns filter 220 221Just log the connection and search filter processing. 222 223E: olcLogLevel none 224 225Log those messages that are logged regardless of the configured loglevel. This 226differs from setting the log level to 0, when no logging occurs. At least the 227{{EX:None}} level is required to have high priority messages logged. 228 229\Default: 230 231E: olcLogLevel stats 232 233Basic stats logging is configured by default. However, if no olcLogLevel is 234defined, no logging occurs (equivalent to a 0 level). 235 236 237H4: olcReferral <URI> 238 239This directive specifies the referral to pass back when slapd 240cannot find a local database to handle a request. 241 242\Example: 243 244> olcReferral: ldap://root.openldap.org 245 246This will refer non-local queries to the global root LDAP server 247at the OpenLDAP Project. Smart LDAP clients can re-ask their 248query at that server, but note that most of these clients are 249only going to know how to handle simple LDAP URLs that 250contain a host part and optionally a distinguished name part. 251 252 253H4: Sample Entry 254 255>dn: cn=config 256>objectClass: olcGlobal 257>cn: config 258>olcIdleTimeout: 30 259>olcLogLevel: Stats 260>olcReferral: ldap://root.openldap.org 261 262 263H3: cn=module 264 265If support for dynamically loaded modules was enabled when configuring 266slapd, {{EX:cn=module}} entries may be used to specify sets of modules to load. 267Module entries must have the {{EX:olcModuleList}} objectClass. 268 269 270H4: olcModuleLoad: <filename> 271 272Specify the name of a dynamically loadable module to load. The filename 273may be an absolute path name or a simple filename. Non-absolute names 274are searched for in the directories specified by the {{EX:olcModulePath}} 275directive. 276 277 278H4: olcModulePath: <pathspec> 279 280Specify a list of directories to search for loadable modules. Typically the 281path is colon-separated but this depends on the operating system. 282 283 284H4: Sample Entries 285 286>dn: cn=module{0},cn=config 287>objectClass: olcModuleList 288>cn: module{0} 289>olcModuleLoad: /usr/local/lib/smbk5pwd.la 290> 291>dn: cn=module{1},cn=config 292>objectClass: olcModuleList 293>cn: module{1} 294>olcModulePath: /usr/local/lib:/usr/local/lib/slapd 295>olcModuleLoad: accesslog.la 296>olcModuleLoad: pcache.la 297 298 299H3: cn=schema 300 301The cn=schema entry holds all of the schema definitions that are hard-coded 302in slapd. As such, the values in this entry are generated by slapd so no 303schema values need to be provided in the config file. The entry must still 304be defined though, to serve as a base for the user-defined schema to add 305in underneath. Schema entries must have the {{EX:olcSchemaConfig}} 306objectClass. 307 308 309H4: olcAttributeTypes: <{{REF:RFC4512}} Attribute Type Description> 310 311This directive defines an attribute type. 312Please see the {{SECT:Schema Specification}} chapter 313for information regarding how to use this directive. 314 315 316H4: olcObjectClasses: <{{REF:RFC4512}} Object Class Description> 317 318This directive defines an object class. 319Please see the {{SECT:Schema Specification}} chapter for 320information regarding how to use this directive. 321 322 323H4: Sample Entries 324 325>dn: cn=schema,cn=config 326>objectClass: olcSchemaConfig 327>cn: schema 328> 329>dn: cn=test,cn=schema,cn=config 330>objectClass: olcSchemaConfig 331>cn: test 332>olcAttributeTypes: ( 1.1.1 333> NAME 'testAttr' 334> EQUALITY integerMatch 335> SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 ) 336>olcAttributeTypes: ( 1.1.2 NAME 'testTwo' EQUALITY caseIgnoreMatch 337> SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.44 ) 338>olcObjectClasses: ( 1.1.3 NAME 'testObject' 339> MAY ( testAttr $ testTwo ) AUXILIARY ) 340 341 342H3: Backend-specific Directives 343 344Backend directives apply to all database instances of the 345same type and, depending on the directive, may be overridden 346by database directives. Backend entries must have the 347{{EX:olcBackendConfig}} objectClass. 348 349H4: olcBackend: <type> 350 351This directive names a backend-specific configuration entry. 352{{EX:<type>}} should be one of the 353supported backend types listed in Table 5.2. 354 355!block table; align=Center; coltags="EX,N"; \ 356 title="Table 5.2: Database Backends" 357Types Description 358bdb Berkeley DB transactional backend 359config Slapd configuration backend 360dnssrv DNS SRV backend 361hdb Hierarchical variant of bdb backend 362ldap Lightweight Directory Access Protocol (Proxy) backend 363ldif Lightweight Data Interchange Format backend 364meta Meta Directory backend 365monitor Monitor backend 366passwd Provides read-only access to {{passwd}}(5) 367perl Perl Programmable backend 368shell Shell (extern program) backend 369sql SQL Programmable backend 370!endblock 371 372\Example: 373 374> olcBackend: bdb 375 376There are no other directives defined for this entry. Specific backend 377types may define additional attributes for their particular use but so 378far none have ever been defined. As such, these directives usually do 379not appear in any actual configurations. 380 381 382H4: Sample Entry 383 384> dn: olcBackend=bdb,cn=config 385> objectClass: olcBackendConfig 386> olcBackend: bdb 387 388 389H3: Database-specific Directives 390 391Directives in this section are supported by every type of database. 392Database entries must have the {{EX:olcDatabaseConfig}} objectClass. 393 394H4: olcDatabase: [{<index>}]<type> 395 396This directive names a specific database instance. The numeric {<index>} may 397be provided to distinguish multiple databases of the same type. Usually the 398index can be omitted, and slapd will generate it automatically. 399{{EX:<type>}} should be one of the 400supported backend types listed in Table 5.2 or the {{EX:frontend}} type. 401 402The {{EX:frontend}} is a special database that is used to hold 403database-level options that should be applied to all the other 404databases. Subsequent database definitions may also override some 405frontend settings. 406 407The {{EX:config}} database is also special; both the {{EX:config}} and 408the {{EX:frontend}} databases are always created implicitly even if they 409are not explicitly configured, and they are created before any other 410databases. 411 412\Example: 413 414> olcDatabase: bdb 415 416This marks the beginning of a new {{TERM:BDB}} database instance. 417 418 419H4: olcAccess: to <what> [ by <who> [<accesslevel>] [<control>] ]+ 420 421This directive grants access (specified by <accesslevel>) to a 422set of entries and/or attributes (specified by <what>) by one or 423more requestors (specified by <who>). 424See the {{SECT:Access Control}} section of this guide for basic usage. 425 426!if 0 427More detailed discussion of this directive can be found in the 428{{SECT:Advanced Access Control}} chapter. 429!endif 430 431Note: If no {{EX:olcAccess}} directives are specified, the default 432access control policy, {{EX:to * by * read}}, allows all 433users (both authenticated and anonymous) read access. 434 435Note: Access controls defined in the frontend are appended to all 436other databases' controls. 437 438 439H4: olcReadonly { TRUE | FALSE } 440 441This directive puts the database into "read-only" mode. Any 442attempts to modify the database will return an "unwilling to 443perform" error. 444 445\Default: 446 447> olcReadonly: FALSE 448 449 450H4: olcRootDN: <DN> 451 452This directive specifies the DN that is not subject to 453access control or administrative limit restrictions for 454operations on this database. The DN need not refer to 455an entry in this database or even in the directory. The 456DN may refer to a SASL identity. 457 458Entry-based Example: 459 460> olcRootDN: "cn=Manager,dc=example,dc=com" 461 462SASL-based Example: 463 464> olcRootDN: "uid=root,cn=example.com,cn=digest-md5,cn=auth" 465 466See the {{SECT:SASL Authentication}} section for information on 467SASL authentication identities. 468 469 470H4: olcRootPW: <password> 471 472This directive can be used to specify a password for the DN for 473the rootdn (when the rootdn is set to a DN within the database). 474 475\Example: 476 477> olcRootPW: secret 478 479It is also permissible to provide a hash of the password in 480{{REF:RFC2307}} form. {{slappasswd}}(8) may be used to generate 481the password hash. 482 483\Example: 484 485> olcRootPW: {SSHA}ZKKuqbEKJfKSXhUbHG3fG8MDn9j1v4QN 486 487The hash was generated using the command {{EX:slappasswd -s secret}}. 488 489 490H4: olcSizeLimit: <integer> 491 492This directive specifies the maximum number of entries to return 493from a search operation. 494 495\Default: 496 497> olcSizeLimit: 500 498 499See the {{SECT:Limits}} section of this guide and slapd-config(5) 500for more details. 501 502 503H4: olcSuffix: <dn suffix> 504 505This directive specifies the DN suffix of queries that will be 506passed to this backend database. Multiple suffix lines can be 507given, and usually at least one is required for each database 508definition. (Some backend types, such as {{EX:frontend}} and 509{{EX:monitor}} use a hard-coded suffix which may not be overridden 510in the configuration.) 511 512\Example: 513 514> olcSuffix: "dc=example,dc=com" 515 516Queries with a DN ending in "dc=example,dc=com" 517will be passed to this backend. 518 519Note: When the backend to pass a query to is selected, slapd 520looks at the suffix value(s) in each database definition in the 521order in which they were configured. Thus, if one database suffix is a 522prefix of another, it must appear after it in the configuration. 523 524 525H4: olcSyncrepl 526 527> olcSyncrepl: rid=<replica ID> 528> provider=ldap[s]://<hostname>[:port] 529> [type=refreshOnly|refreshAndPersist] 530> [interval=dd:hh:mm:ss] 531> [retry=[<retry interval> <# of retries>]+] 532> searchbase=<base DN> 533> [filter=<filter str>] 534> [scope=sub|one|base] 535> [attrs=<attr list>] 536> [attrsonly] 537> [sizelimit=<limit>] 538> [timelimit=<limit>] 539> [schemachecking=on|off] 540> [bindmethod=simple|sasl] 541> [binddn=<DN>] 542> [saslmech=<mech>] 543> [authcid=<identity>] 544> [authzid=<identity>] 545> [credentials=<passwd>] 546> [realm=<realm>] 547> [secprops=<properties>] 548> [starttls=yes|critical] 549> [tls_cert=<file>] 550> [tls_key=<file>] 551> [tls_cacert=<file>] 552> [tls_cacertdir=<path>] 553> [tls_reqcert=never|allow|try|demand] 554> [tls_ciphersuite=<ciphers>] 555> [tls_crlcheck=none|peer|all] 556> [logbase=<base DN>] 557> [logfilter=<filter str>] 558> [syncdata=default|accesslog|changelog] 559 560 561This directive specifies the current database as a replica of the 562master content by establishing the current {{slapd}}(8) as a 563replication consumer site running a syncrepl replication engine. 564The master database is located at the replication provider site 565specified by the {{EX:provider}} parameter. The replica database is 566kept up-to-date with the master content using the LDAP Content 567Synchronization protocol. See {{REF:RFC4533}} 568for more information on the protocol. 569 570The {{EX:rid}} parameter is used for identification of the current 571{{EX:syncrepl}} directive within the replication consumer server, 572where {{EX:<replica ID>}} uniquely identifies the syncrepl specification 573described by the current {{EX:syncrepl}} directive. {{EX:<replica ID>}} 574is non-negative and is no more than three decimal digits in length. 575 576The {{EX:provider}} parameter specifies the replication provider site 577containing the master content as an LDAP URI. The {{EX:provider}} 578parameter specifies a scheme, a host and optionally a port where the 579provider slapd instance can be found. Either a domain name or IP 580address may be used for <hostname>. Examples are 581{{EX:ldap://provider.example.com:389}} or {{EX:ldaps://192.168.1.1:636}}. 582If <port> is not given, the standard LDAP port number (389 or 636) is used. 583Note that the syncrepl uses a consumer-initiated protocol, and hence its 584specification is located at the consumer site, whereas the {{EX:replica}} 585specification is located at the provider site. {{EX:syncrepl}} and 586{{EX:replica}} directives define two independent replication 587mechanisms. They do not represent the replication peers of each other. 588 589The content of the syncrepl replica is defined using a search 590specification as its result set. The consumer slapd will 591send search requests to the provider slapd according to the search 592specification. The search specification includes {{EX:searchbase}}, 593{{EX:scope}}, {{EX:filter}}, {{EX:attrs}}, {{EX:attrsonly}}, 594{{EX:sizelimit}}, and {{EX:timelimit}} parameters as in the normal 595search specification. The {{EX:searchbase}} parameter has no 596default value and must always be specified. The {{EX:scope}} defaults 597to {{EX:sub}}, the {{EX:filter}} defaults to {{EX:(objectclass=*)}}, 598{{EX:attrs}} defaults to {{EX:"*,+"}} to replicate all user and operational 599attributes, and {{EX:attrsonly}} is unset by default. Both {{EX:sizelimit}} 600and {{EX:timelimit}} default to "unlimited", and only positive integers 601or "unlimited" may be specified. 602 603The {{TERM[expand]LDAP Sync}} protocol has two operation 604types: {{EX:refreshOnly}} and {{EX:refreshAndPersist}}. 605The operation type is specified by the {{EX:type}} parameter. 606In the {{EX:refreshOnly}} operation, the next synchronization search operation 607is periodically rescheduled at an interval time after each 608synchronization operation finishes. The interval is specified 609by the {{EX:interval}} parameter. It is set to one day by default. 610In the {{EX:refreshAndPersist}} operation, a synchronization search 611remains persistent in the provider {{slapd}} instance. Further updates to the 612master replica will generate {{EX:searchResultEntry}} to the consumer slapd 613as the search responses to the persistent synchronization search. 614 615If an error occurs during replication, the consumer will attempt to reconnect 616according to the retry parameter which is a list of the <retry interval> 617and <# of retries> pairs. For example, retry="60 10 300 3" lets the consumer 618retry every 60 seconds for the first 10 times and then retry every 300 seconds 619for the next three times before stop retrying. + in <# of retries> means 620indefinite number of retries until success. 621 622The schema checking can be enforced at the LDAP Sync consumer site 623by turning on the {{EX:schemachecking}} parameter. 624If it is turned on, every replicated entry will be checked for its 625schema as the entry is stored into the replica content. 626Every entry in the replica should contain those attributes 627required by the schema definition. 628If it is turned off, entries will be stored without checking 629schema conformance. The default is off. 630 631The {{EX:binddn}} parameter gives the DN to bind as for the 632syncrepl searches to the provider slapd. It should be a DN 633which has read access to the replication content in the 634master database. 635 636The {{EX:bindmethod}} is {{EX:simple}} or {{EX:sasl}}, 637depending on whether simple password-based authentication or 638{{TERM:SASL}} authentication is to be used when connecting 639to the provider {{slapd}} instance. 640 641Simple authentication should not be used unless adequate data 642integrity and confidentiality protections are in place (e.g. TLS 643or IPsec). Simple authentication requires specification of {{EX:binddn}} 644and {{EX:credentials}} parameters. 645 646SASL authentication is generally recommended. SASL authentication 647requires specification of a mechanism using the {{EX:saslmech}} parameter. 648Depending on the mechanism, an authentication identity and/or 649credentials can be specified using {{EX:authcid}} and {{EX:credentials}}, 650respectively. The {{EX:authzid}} parameter may be used to specify 651an authorization identity. 652 653The {{EX:realm}} parameter specifies a realm which a certain 654mechanisms authenticate the identity within. The {{EX:secprops}} 655parameter specifies Cyrus SASL security properties. 656 657The {{EX:starttls}} parameter specifies use of the StartTLS extended 658operation to establish a TLS session before authenticating to the provider. 659If the {{EX:critical}} argument is supplied, the session will be aborted 660if the StartTLS request fails. Otherwise the syncrepl session continues 661without TLS. Note that the main slapd TLS settings are not used by the 662syncrepl engine; by default the TLS parameters from a {{ldap.conf}}(5) 663configuration file will be used. TLS settings may be specified here, 664in which case any {{ldap.conf}}(5) settings will be completely ignored. 665 666Rather than replicating whole entries, the consumer can query logs 667of data modifications. This mode of operation is referred to as 668{{delta syncrepl}}. In addition to the above parameters, the 669{{EX:logbase}} and {{EX:logfilter}} parameters must be set appropriately 670for the log that will be used. The {{EX:syncdata}} parameter must 671be set to either {{EX:"accesslog"}} if the log conforms to the 672{{slapo-accesslog}}(5) log format, or {{EX:"changelog"}} if the log 673conforms to the obsolete {{changelog}} format. If the {{EX:syncdata}} 674parameter is omitted or set to {{EX:"default"}} then the log 675parameters are ignored. 676 677The {{syncrepl}} replication mechanism is supported by the {{bdb}} and 678{{hdb}} backends. 679 680See the {{SECT:LDAP Sync Replication}} chapter of this guide for 681more information on how to use this directive. 682 683 684H4: olcTimeLimit: <integer> 685 686This directive specifies the maximum number of seconds (in real 687time) slapd will spend answering a search request. If a 688request is not finished in this time, a result indicating an 689exceeded timelimit will be returned. 690 691\Default: 692 693> olcTimeLimit: 3600 694 695See the {{SECT:Limits}} section of this guide and slapd-config(5) 696for more details. 697 698 699H4: olcUpdateref: <URL> 700 701This directive is only applicable in a slave slapd. It 702specifies the URL to return to clients which submit update 703requests upon the replica. 704If specified multiple times, each {{TERM:URL}} is provided. 705 706\Example: 707 708> olcUpdateref: ldap://master.example.net 709 710 711H4: Sample Entries 712 713>dn: olcDatabase=frontend,cn=config 714>objectClass: olcDatabaseConfig 715>objectClass: olcFrontendConfig 716>olcDatabase: frontend 717>olcReadOnly: FALSE 718> 719>dn: olcDatabase=config,cn=config 720>objectClass: olcDatabaseConfig 721>olcDatabase: config 722>olcRootDN: cn=Manager,dc=example,dc=com 723 724 725H3: BDB and HDB Database Directives 726 727Directives in this category apply to both the {{TERM:BDB}} 728and the {{TERM:HDB}} database. 729They are used in an olcDatabase entry in addition to the generic 730database directives defined above. For a complete reference 731of BDB/HDB configuration directives, see {{slapd-bdb}}(5). In 732addition to the {{EX:olcDatabaseConfig}} objectClass, BDB and HDB 733database entries must have the {{EX:olcBdbConfig}} and 734{{EX:olcHdbConfig}} objectClass, respectively. 735 736 737H4: olcDbDirectory: <directory> 738 739This directive specifies the directory where the BDB files 740containing the database and associated indices live. 741 742\Default: 743 744> olcDbDirectory: /usr/local/var/openldap-data 745 746 747H4: olcDbCachesize: <integer> 748 749This directive specifies the size in entries of the in-memory 750cache maintained by the BDB backend database instance. 751 752\Default: 753 754> olcDbCachesize: 1000 755 756 757H4: olcDbCheckpoint: <kbyte> <min> 758 759This directive specifies how often to checkpoint the BDB transaction log. 760A checkpoint operation flushes the database buffers to disk and writes a 761checkpoint record in the log. 762The checkpoint will occur if either <kbyte> data has been written or 763<min> minutes have passed since the last checkpoint. Both arguments default 764to zero, in which case they are ignored. When the <min> argument is 765non-zero, an internal task will run every <min> minutes to perform the 766checkpoint. See the Berkeley DB reference guide for more details. 767 768\Example: 769 770> olcDbCheckpoint: 1024 10 771 772 773H4: olcDbConfig: <DB_CONFIG setting> 774 775This attribute specifies a configuration directive to be placed in the 776{{EX:DB_CONFIG}} file of the database directory. At server startup time, if 777no such file exists yet, the {{EX:DB_CONFIG}} file will be created and the 778settings in this attribute will be written to it. If the file exists, 779its contents will be read and displayed in this attribute. The attribute 780is multi-valued, to accommodate multiple configuration directives. No default 781is provided, but it is essential to use proper settings here to get the 782best server performance. 783 784Any changes made to this attribute will be written to the {{EX:DB_CONFIG}} 785file and will cause the database environment to be reset so the changes 786can take immediate effect. If the environment cache is large and has not 787been recently checkpointed, this reset operation may take a long time. It 788may be advisable to manually perform a single checkpoint using the Berkeley DB 789{{db_checkpoint}} utility before using LDAP Modify to change this 790attribute. 791 792\Example: 793 794> olcDbConfig: set_cachesize 0 10485760 0 795> olcDbConfig: set_lg_bsize 2097512 796> olcDbConfig: set_lg_dir /var/tmp/bdb-log 797> olcDbConfig: set_flags DB_LOG_AUTOREMOVE 798 799In this example, the BDB cache is set to 10MB, the BDB transaction log 800buffer size is set to 2MB, and the transaction log files are to be stored 801in the /var/tmp/bdb-log directory. Also a flag is set to tell BDB to 802delete transaction log files as soon as their contents have been 803checkpointed and they are no longer needed. Without this setting the 804transaction log files will continue to accumulate until some other 805cleanup procedure removes them. See the Berkeley DB documentation for the 806{{EX:db_archive}} command for details. For a complete list of Berkeley DB 807flags please see - {{URL:http://www.oracle.com/technology/documentation/berkeley-db/db/api_c/env_set_flags.html}} 808 809Ideally the BDB cache must be 810at least as large as the working set of the database, the log buffer size 811should be large enough to accommodate most transactions without overflowing, 812and the log directory must be on a separate physical disk from the main 813database files. And both the database directory and the log directory 814should be separate from disks used for regular system activities such as 815the root, boot, or swap filesystems. See the FAQ-o-Matic and the Berkeley DB 816documentation for more details. 817 818 819H4: olcDbNosync: { TRUE | FALSE } 820 821This option causes on-disk database contents to not be immediately 822synchronized with in memory changes upon change. Setting this option 823to {{EX:TRUE}} may improve performance at the expense of data integrity. This 824directive has the same effect as using 825> olcDbConfig: set_flags DB_TXN_NOSYNC 826 827 828H4: olcDbIDLcacheSize: <integer> 829 830Specify the size of the in-memory index cache, in index slots. The 831default is zero. A larger value will speed up frequent searches of 832indexed entries. The optimal size will depend on the data and search 833characteristics of the database, but using a number three times 834the entry cache size is a good starting point. 835 836\Example: 837 838> olcDbIDLcacheSize: 3000 839 840 841H4: olcDbIndex: {<attrlist> | default} [pres,eq,approx,sub,none] 842 843This directive specifies the indices to maintain for the given 844attribute. If only an {{EX:<attrlist>}} is given, the default 845indices are maintained. The index keywords correspond to the 846common types of matches that may be used in an LDAP search filter. 847 848\Example: 849 850> olcDbIndex: default pres,eq 851> olcDbIndex: uid 852> olcDbIndex: cn,sn pres,eq,sub 853> olcDbIndex: objectClass eq 854 855The first line sets the default set of indices to maintain to 856present and equality. The second line causes the default (pres,eq) 857set of indices to be maintained for the {{EX:uid}} attribute type. 858The third line causes present, equality, and substring indices to 859be maintained for {{EX:cn}} and {{EX:sn}} attribute types. The 860fourth line causes an equality index for the {{EX:objectClass}} 861attribute type. 862 863There is no index keyword for inequality matches. Generally these 864matches do not use an index. However, some attributes do support 865indexing for inequality matches, based on the equality index. 866 867A substring index can be more explicitly specified as {{EX:subinitial}}, 868{{EX:subany}}, or {{EX:subfinal}}, corresponding to the three 869possible components 870of a substring match filter. A subinitial index only indexes 871substrings that appear at the beginning of an attribute value. 872A subfinal index only indexes substrings that appear at the end 873of an attribute value, while subany indexes substrings that occur 874anywhere in a value. 875 876Note that by default, setting an index for an attribute also 877affects every subtype of that attribute. E.g., setting an equality 878index on the {{EX:name}} attribute causes {{EX:cn}}, {{EX:sn}}, and every other 879attribute that inherits from {{EX:name}} to be indexed. 880 881By default, no indices are maintained. It is generally advised 882that minimally an equality index upon objectClass be maintained. 883 884> olcDbindex: objectClass eq 885 886Additional indices should be configured corresponding to the 887most common searches that are used on the database. 888Presence indexing should not be configured for an attribute 889unless the attribute occurs very rarely in the database, and 890presence searches on the attribute occur very frequently during 891normal use of the directory. Most applications don't use presence 892searches, so usually presence indexing is not very useful. 893 894If this setting is changed while slapd is running, an internal task 895will be run to generate the changed index data. All server operations 896can continue as normal while the indexer does its work. If slapd is 897stopped before the index task completes, indexing will have to be 898manually completed using the slapindex tool. 899 900 901H4: olcDbLinearIndex: { TRUE | FALSE } 902 903If this setting is {{EX:TRUE}} slapindex will index one attribute 904at a time. The default settings is {{EX:FALSE}} in which case all 905indexed attributes of an entry are processed at the same time. When 906enabled, each indexed attribute is processed individually, using 907multiple passes through the entire database. This option improves 908slapindex performance when the database size exceeds the BDB cache 909size. When the BDB cache is large enough, this option is not needed 910and will decrease performance. Also by default, slapadd performs 911full indexing and so a separate slapindex run is not needed. With 912this option, slapadd does no indexing and slapindex must be used. 913 914 915H4: olcDbMode: { <octal> | <symbolic> } 916 917This directive specifies the file protection mode that newly 918created database index files should have. This can be in the form 919{{EX:0600}} or {{EX:-rw-------}} 920 921\Default: 922 923> olcDbMode: 0600 924 925 926H4: olcDbSearchStack: <integer> 927 928Specify the depth of the stack used for search filter evaluation. 929Search filters are evaluated on a stack to accommodate nested {{EX:AND}} / 930{{EX:OR}} clauses. An individual stack is allocated for each server thread. 931The depth of the stack determines how complex a filter can be evaluated 932without requiring any additional memory allocation. Filters that are 933nested deeper than the search stack depth will cause a separate stack to 934be allocated for that particular search operation. These separate allocations 935can have a major negative impact on server performance, but specifying 936too much stack will also consume a great deal of memory. Each search 937uses 512K bytes per level on a 32-bit machine, or 1024K bytes per level 938on a 64-bit machine. The default stack depth is 16, thus 8MB or 16MB 939per thread is used on 32 and 64 bit machines, respectively. Also the 940512KB size of a single stack slot is set by a compile-time constant which 941may be changed if needed; the code must be recompiled for the change 942to take effect. 943 944\Default: 945 946> olcDbSearchStack: 16 947 948 949H4: olcDbShmKey: <integer> 950 951Specify a key for a shared memory BDB environment. By default the BDB 952environment uses memory mapped files. If a non-zero value is specified, 953it will be used as the key to identify a shared memory region that will 954house the environment. 955 956\Example: 957 958> olcDbShmKey: 42 959 960 961H4: Sample Entry 962 963>dn: olcDatabase=hdb,cn=config 964>objectClass: olcDatabaseConfig 965>objectClass: olcHdbConfig 966>olcDatabase: hdb 967>olcSuffix: "dc=example,dc=com" 968>olcDbDirectory: /usr/local/var/openldap-data 969>olcDbCacheSize: 1000 970>olcDbCheckpoint: 1024 10 971>olcDbConfig: set_cachesize 0 10485760 0 972>olcDbConfig: set_lg_bsize 2097152 973>olcDbConfig: set_lg_dir /var/tmp/bdb-log 974>olcDbConfig: set_flags DB_LOG_AUTOREMOVE 975>olcDbIDLcacheSize: 3000 976>olcDbIndex: objectClass eq 977 978 979H2: Configuration Example 980 981The following is an example configuration, interspersed 982with explanatory text. It defines two databases to handle 983different parts of the {{TERM:X.500}} tree; both are {{TERM:BDB}} 984database instances. The line numbers shown are provided for 985reference only and are not included in the actual file. First, the 986global configuration section: 987 988E: 1. # example config file - global configuration entry 989E: 2. dn: cn=config 990E: 3. objectClass: olcGlobal 991E: 4. cn: config 992E: 5. olcReferral: ldap://root.openldap.org 993E: 6. 994 995Line 1 is a comment. Lines 2-4 identify this as the global 996configuration entry. 997The {{EX:olcReferral:}} directive on line 5 998means that queries not local to one of the databases defined 999below will be referred to the LDAP server running on the 1000standard port (389) at the host {{EX:root.openldap.org}}. 1001Line 6 is a blank line, indicating the end of this entry. 1002 1003E: 7. # internal schema 1004E: 8. dn: cn=schema,cn=config 1005E: 9. objectClass: olcSchemaConfig 1006E: 10. cn: schema 1007E: 11. 1008 1009Line 7 is a comment. Lines 8-10 identify this as the root of 1010the schema subtree. The actual schema definitions in this entry 1011are hardcoded into slapd so no additional attributes are specified here. 1012Line 11 is a blank line, indicating the end of this entry. 1013 1014E: 12. # include the core schema 1015E: 13. include: file:///usr/local/etc/openldap/schema/core.ldif 1016E: 14. 1017 1018Line 12 is a comment. Line 13 is an LDIF include directive which 1019accesses the {{core}} schema definitions in LDIF format. Line 14 1020is a blank line. 1021 1022Next comes the database definitions. The first database is the 1023special {{EX:frontend}} database whose settings are applied globally 1024to all the other databases. 1025 1026E: 15. # global database parameters 1027E: 16. dn: olcDatabase=frontend,cn=config 1028E: 17. objectClass: olcDatabaseConfig 1029E: 18. olcDatabase: frontend 1030E: 19. olcAccess: to * by * read 1031E: 20. 1032 1033Line 15 is a comment. Lines 16-18 identify this entry as the global 1034database entry. Line 19 is a global access control. It applies to all 1035entries (after any applicable database-specific access controls). 1036 1037The next entry defines a BDB backend that will handle queries for things 1038in the "dc=example,dc=com" portion of the tree. Indices are to be maintained 1039for several attributes, and the {{EX:userPassword}} attribute is to be 1040protected from unauthorized access. 1041 1042E: 21. # BDB definition for example.com 1043E: 22. dn: olcDatabase=bdb,cn=config 1044E: 23. objectClass: olcDatabaseConfig 1045E: 24. objectClass: olcBdbConfig 1046E: 25. olcDatabase: bdb 1047E: 26. olcSuffix: "dc=example,dc=com" 1048E: 27. olcDbDirectory: /usr/local/var/openldap-data 1049E: 28. olcRootDN: "cn=Manager,dc=example,dc=com" 1050E: 29. olcRootPW: secret 1051E: 30. olcDbIndex: uid pres,eq 1052E: 31. olcDbIndex: cn,sn,uid pres,eq,approx,sub 1053E: 32. olcDbIndex: objectClass eq 1054E: 33. olcAccess: to attrs=userPassword 1055E: 34. by self write 1056E: 35. by anonymous auth 1057E: 36. by dn.base="cn=Admin,dc=example,dc=com" write 1058E: 37. by * none 1059E: 38. olcAccess: to * 1060E: 39. by self write 1061E: 40. by dn.base="cn=Admin,dc=example,dc=com" write 1062E: 41. by * read 1063E: 42. 1064 1065Line 21 is a comment. Lines 22-25 identify this entry as a BDB database 1066configuration entry. Line 26 specifies the DN suffix 1067for queries to pass to this database. Line 27 specifies the directory 1068in which the database files will live. 1069 1070Lines 28 and 29 identify the database {{super-user}} entry and associated 1071password. This entry is not subject to access control or size or 1072time limit restrictions. 1073 1074Lines 30 through 32 indicate the indices to maintain for various 1075attributes. 1076 1077Lines 33 through 41 specify access control for entries in this 1078database. For all applicable entries, the {{EX:userPassword}} attribute is writable 1079by the entry itself and by the "admin" entry. It may be used for 1080authentication/authorization purposes, but is otherwise not readable. 1081All other attributes are writable by the entry and the "admin" 1082entry, but may be read by all users (authenticated or not). 1083 1084Line 42 is a blank line, indicating the end of this entry. 1085 1086The next section of the example configuration file defines another 1087BDB database. This one handles queries involving the 1088{{EX:dc=example,dc=net}} subtree but is managed by the same entity 1089as the first database. Note that without line 52, the read access 1090would be allowed due to the global access rule at line 19. 1091 1092E: 43. # BDB definition for example.net 1093E: 44. dn: olcDatabase=bdb,cn=config 1094E: 45. objectClass: olcDatabaseConfig 1095E: 46. objectClass: olcBdbConfig 1096E: 47. olcDatabase: bdb 1097E: 48. olcSuffix: "dc=example,dc=net" 1098E: 49. olcDbDirectory: /usr/local/var/openldap-data-net 1099E: 50. olcRootDN: "cn=Manager,dc=example,dc=com" 1100E: 51. olcDbIndex: objectClass eq 1101E: 52. olcAccess: to * by users read 1102 1103 1104H2: Converting old style {{slapd.conf}}(5) file to {{cn=config}} format 1105 1106An existing {{slapd.conf}}(5) file can be converted to the new format using 1107{{slaptest}}(8) or any of the slap tools: 1108 1109> slaptest -f /usr/local/etc/openldap/slapd.conf -F /usr/local/etc/openldap/slapd.d 1110 1111You can then discard the old {{slapd.conf}}(5) file. Make sure to launch 1112{{slapd}}(8) with the {{-F}} option to specify the configuration directory. 1113 1114Note: When converting from the slapd.conf format to slapd.d format, any 1115included files will also be integrated into the resulting configuration 1116database. 1117