⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbtools.sdf

📁 OpenLdap是LDAP的开源项目
💻 SDF
字号:
# $OpenLDAP: pkg/openldap-guide/admin/dbtools.sdf,v 1.23.2.2 2007/01/02 21:43:43 kurt Exp $# Copyright 1999-2007 The OpenLDAP Foundation, All Rights Reserved.# COPYING RESTRICTIONS APPLY, see COPYRIGHT.H1: Database Creation and Maintenance ToolsThis section tells you how to create a slapd database from scratch,and how to do trouble shooting if you run into problems. There aretwo ways to create a database. First, you can create the databaseon-line using LDAP. With this method, you simply start up slapdand add entries using the LDAP client of your choice. This methodis fine for relatively small databases (a few hundred or thousandentries, depending on your requirements). This method works fordatabase types which support updates.The second method of database creation is to do it off-line usingspecial utilities provided with slapd. This method is best if youhave many thousands of entries to create, which would take anunacceptably long time using the LDAP method, or if you want toensure the database is not accessed while it is being created. Notethat not all database types support these utilitites.H2: Creating a database over LDAPWith this method, you use the LDAP client of your choice (e.g.,the {{ldapadd}}(1)) to add entries, just like you would once thedatabase is created.  You should be sure to set the followingoptions in the configuration file before starting {{slapd}}(8). >	suffix <dn>As described in the {{SECT:General Database Directives}} section,this option defines which entries are to be held by this database.You should set this to the DN of the root of the subtree you aretrying to create.  For example:>	suffix "dc=example,dc=com"You should be sure to specify a directory where the index filesshould be created:>	directory <directory>For example:>	directory /usr/local/var/openldap-dataYou need to create this directory with appropriate permissions suchthat slapd can write to it.You need to configure slapd so that you can connect to it as adirectory user with permission to add entries. You can configurethe directory to support a special {{super-user}} or {{root}} userjust for this purpose. This is done through the following twooptions in the database definition:>	rootdn <dn>>	rootpw <passwd>For example:>	rootdn "cn=Manager,dc=example,dc=com">	rootpw secretThese options specify a DN and password that can be used toauthenticate as the {{super-user}} entry of the database (i.e.,the entry allowed to do anything). The DN and password specifiedhere will always work, regardless of whether the entry named actuallyexists or has the password given. This solves the chicken-and-eggproblem of how to authenticate and add entries before any entriesyet exist.Finally, you should make sure that the database definition containsthe index definitions you want:>	index {<attrlist> | default} [pres,eq,approx,sub,none]For example, to index the {{EX:cn}}, {{EX:sn}}, {{EX:uid}} and{{EX:objectclass}} attributes, the following {{EX:index}} directivescould be used:>	index cn,sn,uid pres,eq,approx,sub>	index objectClass eqThis would create presence, equality, approximate, and substringindices for the {{EX:cn}}, {{EX:sn}}, and {{EX:uid}} attributes andan equality index for the {{EX:objectClass}} attribute.  Note thatnot all index types are available with all attribute types.  See{{SECT:The slapd Configuration File}} section for more informationon this option.Once you have configured things to your liking, start up slapd,connect with your LDAP client, and start adding entries.  Forexample, to add an organization entry and an organizational roleentry using the {{I:ldapadd}} tool, you could create an {{TERM:LDIF}}file called {{EX:entries.ldif}} with the contents:>	# Organization for Example Corporation>	dn: dc=example,dc=com>	objectClass: dcObject>	objectClass: organization>	dc: example>	o: Example Corporation>	description: The Example Corporation>>	# Organizational Role for Directory Manager>	dn: cn=Manager,dc=example,dc=com>	objectClass: organizationalRole>	cn: Manager>	description: Directory Managerand then use a command like this to actually create the entry:>	ldapadd -f entries.ldif -x -D "cn=Manager,dc=example,dc=com" -w secretThe above command assumes settings provided in the above examples.H2: Creating a database off-lineThe second method of database creation is to do it off-line, usingthe slapd database tools described below. This method is best ifyou have many thousands of entries to create, which would take anunacceptably long time to add using the LDAP method described above.These tools read the slapd configuration file and an input filecontaining a text representation of the entries to add. For databasetypes which support the tools, they produce the database filesdirectly (otherwise you must use the on-line method above). Thereare several important configuration options you will want to besure and set in the config file database definition first:>	suffix <dn>As described in the {{SECT:General Database Directives}} section,this option defines which entries are to be held by this database.You should set this to the DN of the root of the subtree you aretrying to create.  For example:>	suffix "dc=example,dc=com"You should be sure to specify a directory where the index filesshould be created:>	directory <directory>For example:>	directory /usr/local/var/openldap-dataFinally, you need to specify which indices you want to build.  Thisis done by one or more index options.>	index {<attrlist> | default} [pres,eq,approx,sub,none]For example:>	index cn,sn,uid pres,eq,approx,sub>	index objectClass eqThis would create presence, equality, approximate, and substringindices for the {{EX:cn}}, {{EX:sn}}, and {{EX:uid}} attributes andan equality index for the {{EX:objectClass}} attribute.  Note thatnot all index types are available with all attribute types.  See{{SECT:The slapd Configuration File}} section for more informationon this option.H3: The {{EX:slapadd}} programOnce you've configured things to your liking, you create the primarydatabase and associated indices by running the {{slapadd}}(8)program:>	slapadd -l <inputfile> -f <slapdconfigfile>>		[-d <debuglevel>] [-n <integer>|-b <suffix>]The arguments have the following meanings:>	-l <inputfile>Specifies the {{TERM:LDIF}} input file containing the entries toadd in text form (described below in the {{SECT:The LDIF text entryformat}} section).>	-f <slapdconfigfile>Specifies the slapd configuration file that tells where to createthe indices, what indices to create, etc.>	-d <debuglevel>Turn on debugging, as specified by {{EX:<debuglevel>}}. The debuglevels are the same as for slapd.  See the {{SECT:Command-LineOptions}} section in {{SECT:Running slapd}}.> 	-n <databasenumber>An optional argument that specifies which database to modify.  Thefirst database listed in the configuration file is {{EX:1}}, thesecond {{EX:2}}, etc. By default, the first database in theconfiguration file is used. Should not be used in conjunction with{{EX:-b}}.>	-b <suffix>An optional argument that specifies which database to modify.  Theprovided suffix is matched against a database {{EX:suffix}} directiveto determine the database number. Should not be used in conjunctionwith {{EX:-n}}.H3: The {{EX:slapindex}} programSometimes it may be necessary to regenerate indices (such as aftermodifying {{slapd.conf}}(5)). This is possible using the {{slapindex}}(8)program.  {{slapindex}} is invoked like this>	slapindex -f <slapdconfigfile>>		[-d <debuglevel>] [-n <databasenumber>|-b <suffix>]Where the {{EX:-f}}, {{EX:-d}}, {{EX:-n}} and {{EX:-b}} optionsare the same as for the {{slapadd}}(1) program.  {{slapindex}}rebuilds all indices based upon the current database contents.H3: The {{EX:slapcat}} programThe {{EX:slapcat}} program is used to dump the database to an{{TERM:LDIF}} file.  This can be useful when you want to make ahuman-readable backup of your database or when you want to edityour database off-line.  The program is invoked like this:>	slapcat -l <filename> -f <slapdconfigfile>>		[-d <debuglevel>] [-n <databasenumber>|-b <suffix>]where {{EX:-n}} or {{EX:-b}} is used to select the database in the{{slapd.conf}}(5) specified using {{EX:-f}}.  The corresponding{{TERM:LDIF}} output is written to standard output or to the filespecified using the {{EX:-l}} option.!if 0H3: The {{EX:ldif}} programThe {{ldif}}(1) program is used to convert arbitrary data valuesto {{TERM:LDIF}} format.  This can be useful when writing a programor script to create the LDIF file you will feed into the {{slapadd}}(8)or {{ldapadd}}(1) program, or when writing a SHELL backend.{{ldif}}(1) takes an attribute description as an argument and readsthe attribute value(s) from standard input.  It produces the LDIFformatted attribute line(s) on standard output. The usage is:> 	ldif [-b] <attrdesc>where {{EX:<attrdesc>}} is an attribute description. Without the{{EX-b}} option, the {{ldif}} program will consider each line ofstandard input to be a separate value of the attribute.>	ldif description << EOF>	 leading space>	# leading hash mark>	EOFThe {{EX:-b}} option can be used to force the {{ldif}} program tointerpret its input as a single raw binary value.  This option isuseful when converting binary data such as a {{EX:jpegPhoto}} or{{EX:audio}} attribute.  For example:>	ldif -b jpegPhoto < photo.jpeg!endifH2: The LDIF text entry formatThe {{TERM[expand]LDIF}} (LDIF) is used to represent LDAP entriesin a simple text format.  This section provides a brief descriptionof the LDIF entry format which complements {{ldif}}(5) and thetechnical specification {{REF:RFC2849}}.The basic form of an entry is:>	# comment>	dn: <distinguished name>>	<attrdesc>: <attrvalue>>	<attrdesc>: <attrvalue>>> 	...Lines starting with a '{{EX:#}}' character are comments.  Anattribute description may be a simple attribute type like {{EX:cn}}or {{EX:objectClass}} or {{EX:1.2.3}} (an {{TERM:OID}} associatedwith an attribute type) or may include options such as {{EX:cn;lang_en_US}}or {{EX:userCertificate;binary}}.A line may be continued by starting the next line with a {{single}}space or tab character.  For example:>	dn: cn=Barbara J Jensen,dc=example,dc=>	 com>	cn: Barbara J>	  Jensenis equivalent to:>	dn: cn=Barbara J Jensen,dc=example,dc=com>	cn: Barbara J JensenMultiple attribute values are specified on separate lines. e.g.,>	cn: Barbara J Jensen>	cn: Babs JensenIf an {{EX:<attrvalue>}} contains non-printing characters or beginswith a space, a colon ('{{EX::}}'), or a less than ('{{EX:<}}'),the {{EX:<attrdesc>}} is followed by a double colon and the base64encoding of the value.  For example, the value "{{EX: begins witha space}}" would be encoded like this:>	cn:: IGJlZ2lucyB3aXRoIGEgc3BhY2U=You can also specify a {{TERM:URL}} containing the attribute value.For example, the following specifies the {{EX:jpegPhoto}} valueshould be obtained from the file {{F:/path/to/file.jpeg}}.>	cn:< file:///path/to/file.jpegMultiple entries within the same LDIF file are separated by blanklines. Here's an example of an LDIF file containing three entries.>	# Barbara's Entry>	dn: cn=Barbara J Jensen,dc=example,dc=com>	cn: Barbara J Jensen>	cn: Babs Jensen>	objectClass: person>	sn: Jensen>>	# Bjorn's Entry>	dn: cn=Bjorn J Jensen,dc=example,dc=com>	cn: Bjorn J Jensen>	cn: Bjorn Jensen>	objectClass: person>	sn: Jensen>	# Base64 encoded JPEG photo>	jpegPhoto:: /9j/4AAQSkZJRgABAAAAAQABAAD/2wBDABALD>	 A4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQ>	 ERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVG>>	# Jennifer's Entry>	dn: cn=Jennifer J Jensen,dc=example,dc=com>	cn: Jennifer J Jensen>	cn: Jennifer Jensen>	objectClass: person>	sn: Jensen>	# JPEG photo from file>	jpegPhoto:< file:///path/to/file.jpegNotice that the {{EX:jpegPhoto}} in Bjorn's entry is base 64 encodedand the {{EX:jpegPhoto}} in Jennifer's entry is obtained from thelocation indicated by the URL.Note: Trailing spaces are not trimmed from values in an LDIF file.Nor are multiple internal spaces compressed. If you don't want themin your data, don't put them there.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -