I don''t suppose anyone has found an easy way to convert OpenLDAP schema into fedora-ds compatible ldif files? We''ve got about 100 attributes defined, and I''m really not looking forward to entering them all by hand... Thanks DC
D Canfield wrote:> I don''t suppose anyone has found an easy way to convert OpenLDAP > schema into fedora-ds compatible ldif files? We''ve got about 100 > attributes defined, and I''m really not looking forward to entering > them all by hand...Not that I know of, but if you post a couple of examples of the attribute types and object classes you need to port, perhaps we can provide something.> > Thanks > DC > > -- > Fedora-directory-users mailing list > Fedora-directory-users@redhat.com > https://www.redhat.com/mailman/listinfo/fedora-directory-users
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
DC / list,
i have a quick and dirty perl script i had cooked up to do this. it was
enough to allow me to convert some openldap schema to FDS. i was able
to successfully start FDS after converting a few of them (samba3, etc).
i probably went about it all wrong. for instance the dn: line is
probably written out incorrectly (i just did what i could to make it
work). i haven''t even tried importing a database using the newly
converted schemas, so your milage will almost certainly vary.
anyway, i''ve pasted it in the message below because i''m not
sure if the
list allows attachments. i hope it''s of some use to people trying to
make the switch from openldap to FDS.
- ------------- SNIP ------------------
#!/usr/bin/perl -w
#
# this is a quick perl script to convert OpenLDAP schema files
# to FDS ldif (schema) files. it is probably not anywhere near
# useful, but it did allow me to convert a few of my .schema
# files and have FDS successfully start with them.
#
# -Nathan Benson (nathan.benson@sourcefire.com)
#
use strict;
die "usage: $0 <openldap.schema>\n" unless my $file = $ARGV[0];
die "$! ''$file''\n" unless -e $file;
my $start;
print "dn: cn=schema\n";
open SCHEMA, $file;
while (<SCHEMA>)
{
~ next if /^(#|$)/;
~ if (/^(objectclass|attributetype)\s/)
~ {
~ print "\n" if ($start);
~ chomp;
~ $_ =~ s/^objectclass/objectclasses:/i;
~ $_ =~ s/^attributetype/attributetypes:/i;
~ $_ =~ s/(\t|\s)/ /;
~ $start = 1;
~ print;
~ }
~ elsif ((/^\s*\w/) && ($start))
~ {
~ chomp;
~ $_ =~ s/^(\s*)/ /;
~ print;
~ }
}
close SCHEMA;
- ------------- SNIP ------------------
D Canfield thus spake on 06/08/2005 07:51 PM:
| I don''t suppose anyone has found an easy way to convert OpenLDAP
schema
| into fedora-ds compatible ldif files? We''ve got about 100 attributes
| defined, and I''m really not looking forward to entering them all by
hand...
|
| Thanks
| DC
|
| --
| Fedora-directory-users mailing list
| Fedora-directory-users@redhat.com
| https://www.redhat.com/mailman/listinfo/fedora-directory-users
|
- --
Nathan Benson
http://sourcefire.com/
1C1A F2C1 82AD F75F 9B6B E501 0D73 DC9B E96B DD96
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQFCqKLpDXPcm+lr3ZYRAhTqAJ0eBY4Z8Jndv7Bn509p5pe9ZsY4VgCgpuG5
+neqFO+KnYQmHs17PvQdaMw=v5oZ
-----END PGP SIGNATURE-----
D Canfield wrote:> I don''t suppose anyone has found an easy way to convert OpenLDAP schema > into fedora-ds compatible ldif files? We''ve got about 100 attributes > defined, and I''m really not looking forward to entering them all by hand...I have been planning on writing a converter in perl for a while now already, and so I started working on it this evening. It''s not exactly what you would call a trivial task, but it''s not incredibly complex, either. I am pretty busy this weekend, but I should have something available by middle/end of next week. Mike -- LDAP Directory Consulting - http://www.netauth.com
Thanks. The script looks pretty useful. I''ve created an OpenLDAP migration section of the wiki - http://directory.fedora.redhat.com/wiki/Howto:OpenLDAPMigration#Schema - and added your script. I left in your name but removed your email address. I can add it back if you like. Nathan Benson wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > DC / list, > > i have a quick and dirty perl script i had cooked up to do this. it was > enough to allow me to convert some openldap schema to FDS. i was able > to successfully start FDS after converting a few of them (samba3, etc). > > i probably went about it all wrong. for instance the dn: line is > probably written out incorrectly (i just did what i could to make it > work). i haven''t even tried importing a database using the newly > converted schemas, so your milage will almost certainly vary. > > anyway, i''ve pasted it in the message below because i''m not sure if the > list allows attachments. i hope it''s of some use to people trying to > make the switch from openldap to FDS. > > - ------------- SNIP ------------------ > > #!/usr/bin/perl -w > # > # this is a quick perl script to convert OpenLDAP schema files > # to FDS ldif (schema) files. it is probably not anywhere near > # useful, but it did allow me to convert a few of my .schema > # files and have FDS successfully start with them. > # > # -Nathan Benson (nathan.benson@sourcefire.com) > # > > > use strict; > > > die "usage: $0 <openldap.schema>\n" unless my $file = $ARGV[0]; > die "$! ''$file''\n" unless -e $file; > > > my $start; > > > print "dn: cn=schema\n"; > > > open SCHEMA, $file; > while (<SCHEMA>) > { > ~ next if /^(#|$)/; > > > ~ if (/^(objectclass|attributetype)\s/) > ~ { > ~ print "\n" if ($start); > ~ chomp; > > > ~ $_ =~ s/^objectclass/objectclasses:/i; > ~ $_ =~ s/^attributetype/attributetypes:/i; > ~ $_ =~ s/(\t|\s)/ /; > > > ~ $start = 1; > ~ print; > ~ } > ~ elsif ((/^\s*\w/) && ($start)) > ~ { > ~ chomp; > ~ $_ =~ s/^(\s*)/ /; > ~ print; > ~ } > } > close SCHEMA; > > - ------------- SNIP ------------------ > > D Canfield thus spake on 06/08/2005 07:51 PM: > | I don''t suppose anyone has found an easy way to convert OpenLDAP schema > | into fedora-ds compatible ldif files? We''ve got about 100 attributes > | defined, and I''m really not looking forward to entering them all by > hand... > | > | Thanks > | DC > | > | -- > | Fedora-directory-users mailing list > | Fedora-directory-users@redhat.com > | https://www.redhat.com/mailman/listinfo/fedora-directory-users > | > > - -- > Nathan Benson > http://sourcefire.com/ > > 1C1A F2C1 82AD F75F 9B6B E501 0D73 DC9B E96B DD96 > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.2.1 (GNU/Linux) > > iD8DBQFCqKLpDXPcm+lr3ZYRAhTqAJ0eBY4Z8Jndv7Bn509p5pe9ZsY4VgCgpuG5 > +neqFO+KnYQmHs17PvQdaMw> =v5oZ > -----END PGP SIGNATURE----- > > -- > Fedora-directory-users mailing list > Fedora-directory-users@redhat.com > https://www.redhat.com/mailman/listinfo/fedora-directory-users
Nathan Benson wrote:> i have a quick and dirty perl script i had cooked up to do this. it was > enough to allow me to convert some openldap schema to FDS. i was able > to successfully start FDS after converting a few of them (samba3, etc).And here is the one which I promised. It does OL schema to LDIF conversion, as well as pretty printing for readability. usage: ./ol-schema-migrate.pl nis.schema > nis.ldif Sorry, I couldn''t think of a better name for the script. Let me know (on the list) if there are any problems with it and I''ll fix them. -- mike
Thanks! I''ve added a link to this script on the http://directory.fedora.redhat.com/wiki/Howto:OpenLDAPMigration page. Mike Jackson wrote:> Nathan Benson wrote: > >> i have a quick and dirty perl script i had cooked up to do this. it was >> enough to allow me to convert some openldap schema to FDS. i was able >> to successfully start FDS after converting a few of them (samba3, etc). > > > And here is the one which I promised. It does OL schema to LDIF > conversion, as well as pretty printing for readability. > > > usage: ./ol-schema-migrate.pl nis.schema > nis.ldif > > > Sorry, I couldn''t think of a better name for the script. Let me know > (on the list) if there are any problems with it and I''ll fix them. > > -- > mike > >------------------------------------------------------------------------ > >#!/usr/bin/perl -w ># ># Convert OpenLDAP schema files into RHDS format with pretty printing ># ># Mike Jackson <mj@sci.fi> 14 June 2005 ># ># GPL license ># > >use strict; > >my @lines = <>; >my @at; >my @oc; >my $at = 0; >my $oc = 0; >my $at_string; >my $oc_string; > > >for (@lines) { > > if ($at) { > s/\n//; > s/ +/ /; > s/\t/ /; > $at_string .= $_; > > if ( /\)$/ ) { > push @at, $at_string; > $at = 0; > $at_string = ""; > } > } > > if ($oc) { > s/ +/ /; > s/\t/ /; > $oc_string .= $_; > > if ( /^\n/ ) { > $oc_string =~ s/\n//; > push @oc, $oc_string; > $oc = 0; > $oc_string = ""; > } > $oc_string =~ s/\n//; > } > > if ( /attribute[t|T]ype/ ) { > $at = 1; > s/\n//; > s/attribute[t|T]ype/attributeTypes:/; > $at_string .= $_; > } > > if ( /object[c|C]lass/ ) { > $oc = 1; > s/\n//; > s/object[c|C]lass/objectClasses:/; > $oc_string .= $_; > } >} > >&seperator; >print "dn: cn=schema\n"; >&seperator; > > >for (@at) { > > s/attributeTypes: \(/attributeTypes: \(\n /; > > s/NAME/\n NAME/; > s/EQUALITY/\n EQUALITY/; > s/SUBSTRING/\n SUBSTRING/; > s/DESC/\n DESC/; > s/SYNTAX/\n SYNTAX/; > s/SUP/\n SUP/; > s/SUBSTR/\n SUBSTR/; > s/SINGLE-VALUE/\n SINGLE-VALUE/; > > s/\)$/\n )/; > s/ \n/\n/g; > > print "$_\n"; > &seperator; >} > >for (@oc) { > > s/objectClasses: \(/objectClasses: \(\n /; > > s/NAME/\n NAME/; > s/SUP/\n SUP/; > s/AUXILIARY/\n AUXILIARY/; > s/STRUCTURAL/\n STRUCTURAL/; > s/DESC/\n DESC/; > s/MUST/\n MUST/; > s/MAY/\n MAY/; > > s/\)$/\n )/; > s/ \n/\n/g; > > print "$_\n"; > &seperator; >} > > >## subs >sub seperator { > print "#\n"; > print "#********************************************************************\n"; > print "#\n"; >} > > >------------------------------------------------------------------------ > >-- >Fedora-directory-users mailing list >Fedora-directory-users@redhat.com >https://www.redhat.com/mailman/listinfo/fedora-directory-users > >
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
hi,
i''ve updated my perl script to do RFC 2252 ordering as well as
formatting. Steven Bonneville (RedHat) brought it to my attention that
RHDS/FDS was very strict about following the RFC while OpenLDAP was not.
~ so, if an OL schema was out of order, it caused problems when being
converted to RHDS/FDS.
anyway, i''ve attached my script. it should also be useful for
reordering already converted schemas just in case the order might not be
correct.
i hope everyone finds it useful, please let me know how it works out.
thanks,
nathan
Nathan Benson thus spake on 06/09/2005 04:13 PM:
| DC / list,
|
| i have a quick and dirty perl script i had cooked up to do this. it was
| enough to allow me to convert some openldap schema to FDS. i was able
| to successfully start FDS after converting a few of them (samba3, etc).
|
| i probably went about it all wrong. for instance the dn: line is
| probably written out incorrectly (i just did what i could to make it
| work). i haven''t even tried importing a database using the newly
| converted schemas, so your milage will almost certainly vary.
|
| anyway, i''ve pasted it in the message below because i''m not
sure if the
| list allows attachments. i hope it''s of some use to people trying to
| make the switch from openldap to FDS.
|
| ------------- SNIP ------------------
|
| #!/usr/bin/perl -w
| #
| # this is a quick perl script to convert OpenLDAP schema files
| # to FDS ldif (schema) files. it is probably not anywhere near
| # useful, but it did allow me to convert a few of my .schema
| # files and have FDS successfully start with them.
| #
| # -Nathan Benson (nathan.benson@sourcefire.com)
| #
|
|
| use strict;
|
|
| die "usage: $0 <openldap.schema>\n" unless my $file =
$ARGV[0];
| die "$! ''$file''\n" unless -e $file;
|
|
| my $start;
|
|
| print "dn: cn=schema\n";
|
|
| open SCHEMA, $file;
| while (<SCHEMA>)
| {
| ~ next if /^(#|$)/;
|
|
| ~ if (/^(objectclass|attributetype)\s/)
| ~ {
| ~ print "\n" if ($start);
| ~ chomp;
|
|
| ~ $_ =~ s/^objectclass/objectclasses:/i;
| ~ $_ =~ s/^attributetype/attributetypes:/i;
| ~ $_ =~ s/(\t|\s)/ /;
|
|
| ~ $start = 1;
| ~ print;
| ~ }
| ~ elsif ((/^\s*\w/) && ($start))
| ~ {
| ~ chomp;
| ~ $_ =~ s/^(\s*)/ /;
| ~ print;
| ~ }
| }
| close SCHEMA;
|
| ------------- SNIP ------------------
|
| D Canfield thus spake on 06/08/2005 07:51 PM:
| | I don''t suppose anyone has found an easy way to convert OpenLDAP
schema
| | into fedora-ds compatible ldif files? We''ve got about 100
attributes
| | defined, and I''m really not looking forward to entering them all by
| hand...
| |
| | Thanks
| | DC
| |
| | --
| | Fedora-directory-users mailing list
| | Fedora-directory-users@redhat.com
| | https://www.redhat.com/mailman/listinfo/fedora-directory-users
| |
|
- --
Fedora-directory-users mailing list
Fedora-directory-users@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-directory-users
- --
Nathan Benson
http://sourcefire.com/
1C1A F2C1 82AD F75F 9B6B E501 0D73 DC9B E96B DD96
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQFDX6f0DXPcm+lr3ZYRAlmAAJ9CgySM8J7KCTdbfhgUQYNPNkrjfACgiNex
saZih7lWJKsgHwCq5z8V5zk=Dhr5
-----END PGP SIGNATURE-----