Reputation: 859
I'm exporting a schema using ldifde but the output file wraps long lines so it's hard to manually edit with thousand's lines.
I have to edit the file because I must replace a string there, for example:
distinguishedName:
CN=xxx-com-Admin-Assistant-yy,CN=Schema,CN=Configuration,-->DC=morel,DC=mis,DC=mo
r-ambiguit,<--DC=com
to
distinguishedName:
CN=xxx-com-Admin-Assistant-yy,CN=Schema,CN=Configuration,-->DC=myDomain,<--DC=com
As you can see I should first unwrap the file and then replace the string, otherwise the replace won't work Any clues on how I should perform that. I tried perl script but not luck. Also I looked into ldifde options.
Thank in advance, m0dest0
Upvotes: 0
Views: 1437
Reputation: 72670
If you strictly want to import the schema from one domain to another using LDIFDE, you can use the -c
parameter from LDIFDE to change one DN to another, see KB237677: Using LDIFDE to import and export directory objects to Active Directory.
-c FromDN ToDN Replace occurrences of FromDN to ToDN
Upvotes: 3
Reputation: 13666
#!/usr/bin/perl
use strict ;
my $orig = do { local $/ ; <DATA> } ;
( my $copy = $orig ) =~ s/(DC=)(.+?)(,DC=com)/$1myDomain$3/xsg ;
printf "Before:\n%s\nAfter:\n%s\n" , $orig , $copy ;
__DATA__
distinguishedName:
CN=xxx-com-Admin-Assistant-yy,CN=Schema,CN=Configuration,DC=morel,DC=mis,DC=mo
r-ambiguit,DC=com
And this will print:
Before:
distinguishedName:
CN=xxx-com-Admin-Assistant-yy,CN=Schema,CN=Configuration,DC=morel,DC=mis,DC=mo
r-ambiguit,DC=com
After:
distinguishedName:
CN=xxx-com-Admin-Assistant-yy,CN=Schema,CN=Configuration,DC=myDomain,DC=com
Upvotes: 2