#!/usr/bin/perl -w # This script takes apple.schema files as input, # and outputs a file suitable for importing into # Sun LDAP (5.2) servers. # Use at your own risk! This script has NO warranty. # By Netmojo Systems (http://www.netmojo.ca) # Thu Mar 27 12:12:42 MDT 2008 # With thanks to rajeev karamchedu @ # http://rajeev.name/blog/2006/09/09/integrating-mac-os-x-into-unix-ldap-environment-with-nfs-home-directories use strict; if( @ARGV < 2 ) { print "\n\n\tUsage: apple2ldif \n\n"; } my $infile = $ARGV[0]; my $outfile = $ARGV[1]; open IN, "$infile" or die "\nError: $!\n"; open OUT, ">$outfile" or die "\nError: $!\n"; if( $infile !~ /samba/ ) { print OUT qq{dn: cn=schema objectClass: top objectClass: ldapSubentry objectClass: subschema cn=schema attributeTypes: ( 1.3.6.1.4.1.63.1000.1.1.2.16.1 NAME 'authAuthority' DESC 'password server authentication authority' EQUALITY caseExactIA5Match SUBSTR caseExactIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) attributeTypes: ( 1.3.6.1.4.1.63.1000.1.1.2.16.2 NAME ( 'authAuthority2' ) DESC 'password server authentication authority 2' EQUALITY caseExactMatch SUBSTR caseExactSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) attributeTypes: ( 1.3.6.1.4.1.63.1000.1.1.1.3.10 NAME 'apple-machine-serves' DESC 'NetInfo Domain Server Binding' EQUALITY caseExactIA5Match SUBSTR caseExactIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) attributeTypes: ( 1.3.6.1.4.1.63.1000.1.1.1.3.11 NAME 'apple-machine-suffix' DESC 'DIT suffix' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) attributeTypes: ( 1.3.6.1.4.1.63.1000.1.1.1.3.12 NAME 'apple-machine-contactperson' DESC 'Name of contact person/owner of this machine' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) objectClasses: ( 1.2.840.113556.1.3.23 NAME 'container' SUP top STRUCTURAL MUST ( cn ) )}; } while() { chomp($_); next if ($_ =~ /^#/ || $_ !~ /[A-Za-z0-9]/); $_ =~ s/\n//g; $_ =~ s/\t/\ /g; $_ =~ s/\s+/\ /g; if ($_ =~ /^attributetype/ ) { $_ =~ s/attributetype/attributeTypes:/g; print OUT "\n"; } if ($_ =~ /^objectclass/) { $_ =~ s/objectclass/objectClasses:/g; print OUT "\n"; } print OUT $_; } close(IN); close(OUT); print "Done.\n";