Hi,
I am about to prepare LDAP data migration and it contains:
- export of 3 LDAP entries to LDIF file;
- conversion of that LDIF file (attr names change and removal) using the schema file;
- import of converted LDIF file to LDAP.
Every phase is done by sh script.
Export is a query of LDAP for a specified objectClass value
(ie.
)
and write to a file.
Result of an export is a following LDIF file:
Schema file is as follows:
I would like to convert exported file using schema file above and get following:
I got some questions about that operation:
- How to do that? and is it safe to use tools like sed or awk in this case?;
- Is it correct that LDAP entry begins with a line different than "dn=..." because I do not know if I can import a file that is exported and converted in the way above and I do not have to change lines order in the entry then.
I have not found a confirmation anywhere but many examples from web always begin with "dn=..."
Big thanks for support.
With regards,
-XYZ
I am about to prepare LDAP data migration and it contains:
- export of 3 LDAP entries to LDIF file;
- conversion of that LDIF file (attr names change and removal) using the schema file;
- import of converted LDIF file to LDAP.
Every phase is done by sh script.
Export is a query of LDAP for a specified objectClass value
(ie.
Code:
# ldapacmx.pl --direcyQuery "(objectClass=Cluster)"
and write to a file.
Result of an export is a following LDIF file:
Code:
cn=Customer
dn=cn=Customer,ou=manager,ou=scconfig,ou=config,ou=region-987654,ou=regions,ou=company,dc=lab,dc=net
CustomerId=123456
CustomerName=ABC
objectClass=top
objectClass=Customer
CompanyTargetId=987654
cn=Cluster
CurrentSerialAlphabet=K
dn=cn=Cluster,ou=manager,ou=scconfig,ou=config,ou=region-987654,ou=regions,ou=company,dc=lab,dc=net
objectClass=top
objectClass=Cluster
ClusterStartAlphabet=K
ClusterEndAlphabet=K
cn=Directory
SystemDefOrderFileDir=OrderAttachments
dn=cn=Directory,ou=manager,ou=scconfig,ou=config,ou=region-987654,ou=regions,ou=company,dc=lab,dc=net
SystemDefImportDir=FilesToImport
objectClass=top
objectClass=Directory
Code:
dn: cn=schema
attributeTypes: (
1.3.6.1.4.1.94.1.55.10.1.1
NAME 'CustomerId'
DESC 'The ID of the customer.'
EQUALITY caseIgnoreMatch
SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
)
#
#********************************************************************
#
attributeTypes: (
1.3.6.1.4.1.94.1.55.10.1.2
NAME 'CustomerName'
DESC 'The Name of the customer.'
EQUALITY caseIgnoreMatch
SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
)
#
#********************************************************************
#
attributeTypes: (
1.3.6.1.4.1.94.1.55.10.1.3
NAME 'ClusterStartAlphabet'
DESC 'The Start Alphabet for the cluster used in generation of ABC
files.'
EQUALITY caseIgnoreMatch
SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
SINGLE-VALUE
)
#
#********************************************************************
#
attributeTypes: (
1.3.6.1.4.1.94.1.55.10.1.4
NAME 'ClusterEndAlphabet'
DESC 'The End Alphabet for the cluster used in generation of ABC
files.'
EQUALITY caseIgnoreMatch
SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
SINGLE-VALUE
)
#
#********************************************************************
#
attributeTypes: (
1.3.6.1.4.1.94.1.55.10.1.5
NAME 'CurrentAlphabet'
DESC 'The running alphabet for generation of ABC files'
EQUALITY caseIgnoreMatch
SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
SINGLE-VALUE
)
#
#********************************************************************
#
attributeTypes: (
1.3.6.1.4.1.94.1.55.10.1.8
NAME 'CompanyTargetId'
DESC 'The Target Id of the Company Cluster'
EQUALITY caseIgnoreMatch
SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
SINGLE-VALUE
)
#
#********************************************************************
#
attributeTypes: (
1.3.6.1.4.1.94.1.55.10.1.6
NAME 'ImportDir'
DESC 'The default directory for importing ABC files.'
EQUALITY caseIgnoreMatch
SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
SINGLE-VALUE
)
#
#
objectClasses: (
1.3.6.1.4.1.94.1.55.10.2.1
NAME 'Customer'
DESC 'The customer specific details.'
SUP top
MUST ( cn $ CustomerId $ CustomerName )
)
#
#********************************************************************
#
objectClasses: (
1.3.6.1.4.1.94.1.55.10.2.2
NAME 'Cluster'
DESC 'The cluster specific details.'
SUP top
MUST ( cn $ ClusterStartAlphabet $ ClusterEndAlphabet $
CurrentAlphabet $ CompanyTargetId)
)
#
#********************************************************************
#
objectClasses: (
1.3.6.1.4.1.94.1.55.10.2.3
NAME 'Directory'
DESC 'The default directories used by ABC application.'
SUP top
MUST ( cn $ ImportDir )
)
#
#********************************************************************
#
#
#
#
# EOF
Code:
cn=customer
dn=cn=customer,ou=manager,ou=scconfig,dc=lab,dc=net
CustomerId=123456
CustomerName=ABC
objectClass=top
objectClass=Customer
CompanyTargetId=987654
cn=cluster
CurrentAlphabet=K
dn=cn=cluster,ou=manager,ou=scconfig,dc=lab,dc=net
objectClass=top
objectClass=Cluster
ClusterStartAlphabet=K
ClusterEndAlphabet=K
cn=directory
dn=cn=directory,ou=manager,ou=scconfig,dc=lab,dc=net
ImportDir=FilesToImport
objectClass=top
objectClass=Directory
- How to do that? and is it safe to use tools like sed or awk in this case?;
- Is it correct that LDAP entry begins with a line different than "dn=..." because I do not know if I can import a file that is exported and converted in the way above and I do not have to change lines order in the entry then.
I have not found a confirmation anywhere but many examples from web always begin with "dn=..."
Big thanks for support.
With regards,
-XYZ