Hi All,
I have an old-address-list file which is having around 1500 entries. I need to convert this addresses in to a specific format.
The old-address-list file>
# cat old-address-list-file
dn: CN=Muhammad Hadhi K.M,OU=IT Dept,OU=Example Company H.O,DC=example,DC=com
cn: Muhammad Hadhi K.M
sn: Hadhi
l: Calicut
title: IT Manager
postalCode: 5456
postOfficeBox: 3434
physicalDeliveryOfficeName: IT Department
telephoneNumber: +111 1 111111 Ext:111
facsimileTelephoneNumber: +222 2 222222
givenName: Muhammad
department: IT
company: Example Company Ltd.
proxyAddresses: SMTP:hadhi@example.com
streetAddress: P.O.Box 3434
mobile: +4444 4444 4444
dn: CN=Gheevar Scaria,OU=Civil,OU=MNM Site,OU=Example Company MNM,DC=example,DC=com
cn: Gheevar Scaria
sn: Scaria
l: Cochin
title: Civil Engineer
postalCode: 2323
postOfficeBox: 4545
physicalDeliveryOfficeName: ABC Office
telephoneNumber: +111 123456789 Ext:111
facsimileTelephoneNumber: +222 212121
givenName: Gheevar
department: Civil Department
company: Example Company Ltd.
proxyAddresses: SMTP:gheevar@mnm-example.com
streetAddress: Nut Street
mobile: +444 12211221
dn: CN=Siva Kumar KP,OU=Marketing,OU=RTZ Site,OU=Example Company RTZ,DC=example,DC=com
cn: Siva Kumar KP
sn: Kumar
l: Tirur
title: Marketing Manager
telephoneNumber: +111 987654321 Ext:999
givenName: Siva
department: Marketing
company: Example Company Ltd.
proxyAddresses: SMTP:siva@rtz-example.com
Few information about this file;
==============================/
1. All addresses starts with dn:
2. So a single address entry means the values begin with a dn: up to the next dn: entry
3. The above example holds 3 valid addresses
4. The maximum values (each line including dn: holds a value) in an address entry is 16 (as the 2 first addresses in this example) (the last address is having only 10 values)
5. Some addresses may have only 4 values (dn:, cn:, sn:, proxyAddresses: SMTP

which are the mandatory, and some others might have values in between this 4 and 16 (its not fixed).
Now the tasks to do;
===================/
1. Need to change all the dn: lines to the following way;
dn: CN=Muhammad Hadhi K.M,ou=Addressbook,dc=good,dc=com
dn: CN=Gheevar Scaria,ou=Addressbook,dc=good,dc=com
dn: CN=Siva Kumar KP,ou=Addressbook,dc=good,dc=com
means need to replace immediately after the "dn: CN=Full Name," with "ou=Addressbook,dc=good,dc=com"
2. Add the following 2 lines to just below all the dn: lines
objectClass: inetOrgPerson
objectClass: top
(this is not an address specific value, this value is same for all the addresses)
3. substitute the following words
"department:"------>to----->"ou:"
"company:"------>to----->"o:"
"proxyAddress: SMTP:"------>to----->"mail":
"streetAddress:"------>to----->"street":
4. Put a blank line between addresses (like a blank line above all the dn: lines)
5. Any procedure to verify the entire process went fine
Expecting Result;
================/
The resulting file should look like this;
# cat new-address-list
dn: cn= Muhammad Hadhi K.M,ou=Addressbook,dc=good,dc=com
objectClass: inetOrgPerson
objectClass: top
cn: Muhammad Hadhi K.M
sn: Hadhi
l: Calicut
title: IT Manager
postalCode: 5456
postOfficeBox: 3434
physicalDeliveryOfficeName: IT Department
telephoneNumber: +111 1 111111 Ext:111
facsimileTelephoneNumber: +222 2 222222
givenName: Muhammad
ou: IT
o: Example Company Ltd.
mail:
hadhi@example.com
mobile: +4444 4444 4444
dn: CN=Gheevar Scaria,ou=Addressbook,dc=good,dc=com
objectClass: inetOrgPerson
objectClass: top
cn: Gheevar Scaria
sn: Scaria
l: Cochin
title: Civil Engineer
postalCode: 2323
postOfficeBox: 4545
physicalDeliveryOfficeName: ABC Office
telephoneNumber: +111 123456789 Ext:111
facsimileTelephoneNumber: +222 212121
givenName: Gheevar
ou: Civil Department
o: Example Company Ltd.
mail:gheevar@mnm-example.com
street: Nut Street
mobile: +444 12211221
dn: CN=Siva Kumar KP,ou=Addressbook,dc=good,dc=com
objectClass: inetOrgPerson
objectClass: top
cn: Siva Kumar KP
sn: Kumar
l: Tirur
title: Marketing Manager
telephoneNumber: +111 987654321 Ext:999
givenName: Siva
ou: Marketing
o: Example Company Ltd.
mail:siva@rtz-example.com
### NOTE ###: i had done this entire procedure (without any verification procedures). But it was not in a professional way, and it is something horrible.
As i am System Admin, who dont have any exposure to the programming side, i feel big difficulty in doing this. Please do provide me a solution for this task.
* * * *
* *
* * /############################\ *
# Bunch of THANKS in Advance...# *
* \############################/ *
* * *
* * * * * * * *
*
KMR