Oracle DBA Tips Corner |
|
Writing LDAP Entries to an LDIF File - (Using ldapwrite and ldapsearch)
by Jeff Hunter, Sr. Database Administrator
Contents
Overview
Exporting Application Data and Values
Exporting Schema or Operational Attributes and Values
Exporting Application Data and Values
Exporting Schema or Operational Attributes and Values
All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter
and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express,
prior, written permission. Application to host any of the material elsewhere can be made by contacting me at jhunter@idevelopment.info.
I have made every effort and taken great care in making sure that the material included on my web site is technically accurate,
but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from
relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.
There are two easy ways in which to write LDAP entries (application data)
to an LDIF flat file. Those two ways are the command-line utilities
ldifwrite or ldapsearch.
Using ldifwrite
ldifwrite is intended for use only on OID "application data", not
the schema or operational attributes and values (e.g., cn=catalogs, cn=changelog, etc.).
Keep in mind that in order to use the command-line utility, you will need to
know and use the ODS database username and password. The syntax for the ldifwrite
command is:
Using ldapsearch
ldifwrite -c <db_connect_string> -b <base DN> -f <filename>
You can type the following commands to export OID application data using ldapwrite:
# ldifwrite -c OIDDB_ALEX -b "o=airius.com" -f airius.ldif
This tool can only be executed if you know database user password for OiD
Enter OiD Password :: ods
As previously mentioned, you cannot use ldifwrite to write out schema or
operational data. In order to extract schema and operational data, you will need to use
ldapsearch (described below). Trying to perform a search of this type, will result in the following
error:
# ldifwrite -c OIDDB_ALEX -b "cn=subschemaSubentry" -f alex_oid_schema.ldif
This tool can only be executed if you know database user password for OiD
Enter OiD Password :: ods
Base DN cn=subschemasubentry not found.
The syntax for the ldifsearch command, while writing out to an LDIF file is:
ldapsearch -L -D "cn=orcladmin" -w "welcome" -h <host> -p <port> -b <base DN> -s <Search Scope (base | one | sub)> "<Search Filter>" > output_file.ldif
You can type the following commands to export OID application data using ldapsearch:
# ldapsearch -L -D "cn=orcladmin" -w "welcome" -h alex -p 389 -b "o=airius.com" -s sub "objectclass=*" > airius.ldif
As previously mentioned, you cannot use ldifwrite to write out schema or
operational data. You can only use to perform this type of operation.
To export the schema or operational attributes and values, you need to use ldapsearch with the
-L option as follows:
# ldapsearch -L -D "cn=orcladmin" -w "welcome" -h alex -p 389 -b "cn=subschemaSubentry" -s base "objectclass=*" > alex_oid_schema.ldif
Monday, 23-Jan-2006 08:50:07 EST
Page Count: 10289