examples:s2→s3-ldif-convert-script: fix objectclass recognition
[samba.git] / examples / LDAP / convertSambaAccount
index d2770c75a687592be7bb1442c1d3e9f544300fe2..8b522ef8ae82d0f19cc913f1281be0cb6d4f5a90 100755 (executable)
@@ -9,6 +9,12 @@
 ##       --input=<input ldif> --output=<output ldif> \
 ##       --changetype=[modify|add]
 ##
+## You can generate an input ldif file using:
+## $ ldapsearch -LL -x -h ldapsrv -D cn=root,dc=company,dc=com \
+##   -b dc=copmany,dc=com > /tmp/samba3.alpha23.ldif
+##
+## Note the "-LL" so no additional comments are generated
+##
 
 
 use strict;
@@ -150,9 +156,9 @@ while ( !$ldif->eof ) {
        @adds = ();
        @dels = ();
        foreach $obj ( @objclasses ) {
-               if ( "$obj" eq "sambaAccount" ) {
+               if ( lc($obj) eq "sambaaccount" ) {
                        $is_samba_account = 1;
-               } elsif ( "$obj" eq "sambaGroupMapping" ) {
+               } elsif ( lc($obj) eq "sambagroupmapping" ) {
                        $is_samba_group = 1;
                }
        }
@@ -170,7 +176,7 @@ while ( !$ldif->eof ) {
                $entry->add( 'sambaSID' => $domsid."-".$entry->get_value( "rid" ) );
                $entry->delete( 'rid' );
        
-               if ( $entry->get_value( "primaryGroupID" ) ) {
+               if ( defined($entry->get_value( "primaryGroupID" )) ) {
                        push @adds, "sambaPrimaryGroupSID: " . $domsid."-".$entry->get_value( "primaryGroupID" );
                        push @dels, "primaryGroupID";
                        $entry->add( 'sambaPrimaryGroupSID' => $domsid."-".$entry->get_value( "primaryGroupID" ) );