Help in Getting specified output format

Hi all,

I have input text file of this format

objectclass:endeavor
pid:12345
postalAddress:379 PROSPECT ST
street:STE B
l:TORRINGTON
st:CT
postalCode:067905238
telephoneNumber:9999999999
facsimileTelephoneNumber:9999999999
objectclass:endeavor
pid:45678
postalAddress:579 RARITAN RD
street:STE A
l:ROSELLE
st:NJ
postalCode:072039999
telephoneNumber:9999999999
facsimileTelephoneNumber:9999999999

And I need the output with format listed below

dn: o=abc,o=xyz,dc=yahoo,dc=com
o: abc
objectClass: organization
objectClass: top

dn: id=N-12345-D,o=abc,o=xyz,dc=yahoo,dc=com
objectclass:top
objectclass:endeavor
pid:12345
postalAddress:379 PROSPECT ST
street:STE B
l:TORRINGTON
st:CT
postalCode:067905238
telephoneNumber:9999999999
facsimileTelephoneNumber:9999999999

dn: id=N-45678-D,o=abc,o=xyz,dc=yahoo,dc=com
objectclass:top
objectclass:endeavor
pid:45678
postalAddress:579 RARITAN RD
street:STE A
l:ROSELLE
st:NJ
postalCode:072039999
telephoneNumber:9999999999
facsimileTelephoneNumber:9999999999

Please help guys.

what have you tried till now??

First, describe, in detail, the steps that must be taken to transform the input to the output.

Then, write the code for each step.

If you have problems with the second part, post the first part, and tell us what you have tried for the second part.