Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: migration of mailboxes & LDAP data

Hybrid View

  1. #1
    Join Date
    Feb 2009
    Posts
    188
    Rep Power
    6

    Exclamation migration of mailboxes & LDAP data

    hi all,
    I am planing for the migration of mailbox data from sun java communication suite 5.
    I have seen the migration links for zimbra, however i have not yet find any right way for it.My question is how i can transfer the format of mailbox from comm suite to zimbra? Is there any command through which i can reconstruct the mailboxes?
    More over the LDAP data was stored in sun java directory server earlier,
    Is there any way of importing user from the LDAp.diff file, if not that any way for modifying the user's password with the hash for the password as same as earlier stored.

    #############################################
    What do you suggest me regarding the migration,


    Best regards
    Adeel

  2. #2
    Join Date
    Nov 2006
    Location
    UK
    Posts
    8,017
    Rep Power
    24

  3. #3
    Join Date
    Jan 2009
    Location
    Fresno
    Posts
    31
    Rep Power
    6

    Default

    If you are interested in a perl migration script that will convert iplanet messaging 5.2's Personal Address Book to a form that will allow you to import it into zimbra, pm me.
    Last edited by fowler; 03-09-2009 at 08:59 AM.

  4. #4
    Join Date
    Jan 2011
    Posts
    1
    Rep Power
    4

    Default export iplanet PAB

    Quote Originally Posted by fowler View Post
    If you are interested in a perl migration script that will convert iplanet messaging 5.2's Personal Address Book to a form that will allow you to import it into zimbra, pm me.
    Do you still have this?

    Many thanks.

  5. #5
    Join Date
    Apr 2012
    Posts
    4
    Rep Power
    3

    Default

    Quote Originally Posted by fowler View Post
    If you are interested in a perl migration script that will convert iplanet messaging 5.2's Personal Address Book to a form that will allow you to import it into zimbra, pm me.
    Hi fowler,

    I'll be grateful if you could share your script for PAB migration.

    Thx in advance

  6. #6
    Join Date
    Jan 2009
    Location
    Fresno
    Posts
    31
    Rep Power
    6

    Default

    Try this. It generates a file that could be used to import contacts into zimbra. You'll need to define some ldap variables below. Test it out and make sure it is something you can use.

    Code:
    #! /usr/bin/perl
    # 
    # [Name]
    # imsPAB2zimbra.pl 
    #
    # [Description]
    # This script exports an individual's iplanet messaging server PAB
    # and converts the export into a form usable by zimbra's zmmailbox tool.
    # Tested against ims5.2.
    #
    # It runs an ldapsearch to locate a user's pab entries 
    # and convert them into a format usable to zmmailbox
    #
    # [Synopsis]
    # - convert the ldap pab into cct commands for importing
    # imsPAB2zimbra.pl jimnorton > results.txt
    #
    # [ Importing ]
    # import the pab using zimbra's zmmailbox command.
    # zimbra@host#  zmmailbox -z -m jimnorton@host.com -f ./results.txt
    #
    # [Other useful commands]
    # - Get all the existing contacts
    # zimbra@host#  zmmailbox -z -m jimnorton@host.com gact
    #
    # - Delete all existing zimbra contacts from given user 
    #    It is recommended this step be skipped!!!!
    # zimbra@host#  zmmailbox -z -m jimnorton@host.com ef /Contacts
    # 
    # ASSUMPTIONS:
    #   1. User's DN and PAB entries are on the same directory server.
    #      If not, then additional tooling is required.  This script 
    #      uses the user's pabURI value to locate their PAB entries.
    #
    #
    #
    # JF - 20090308
    #
    
    use Net::LDAP;
    
    
    ########################################################################
    # Directory server settings
    # Description: The user's pabURI is used to locate their PAB
    # - Define the following 
    ########################################################################
    my $ldapHost = 'ldapserver.somehost.com';
    my $ldapPort = '389';
    my $ldapBind = 'cn=directory manager';
    my $ldapPass = 'xxxxxxx';
    my $ldapBaseDN = 'o=ABC Corp,dc=somehost,dc=com'; # where you expect to find the user's DN
    my $ldapScope  = 'sub';
    ########################################################################
    
    # iplanet attribute => zimbra attr
    my %sun2zimPerson = (
        'cn'                       => 'fullName',
        'givenname'                => 'firstName',
        'sn'                       => 'lastName',
        'mail'                     => 'email',
        'telephonenumber'          => 'workPhone',
        'mobile'                   => 'mobilePhone',
        'pager'                    => 'pager',
        'facsimiletelephonenumber' => 'workFax',
        'street'                   => 'workStreet',
        'l'                        => 'workCity',
        'st'                       => 'workState',
        'postalcode'               => 'workPostalCode',
        'co'                       => 'workCountry',
        'dateofbirth'              => 'birthday',
        'labeleduri'               => 'workURL',
        'description'              => 'notes'
    );
    
    
    my $uid = shift or die "$0 <uid>\n";
    
    # The iPlanet PAB is converted into a file that can be imported into Zimbra.
    # This file is locate here:
    my $output = '/tmp/' . $uid . '.import';
    
    
    # connect and locate the user's paburi
    my $ldap = Net::LDAP->new( $ldapHost, port => $ldapPort ) or die "$@";
    my $mesg = $ldap->bind( $ldapBind, password => $ldapPass ) or die $!;
    my $res = $ldap->search( base => $ldapBaseDN, scope => 'sub', filter => '(uid=' . $uid . ')', attrs => ['paburi']);
    $res->code && die $res->error;
    $res->count != 1 && die "More than one result returned\n";
    my $paburi = $res->entry(0)->get_value('paburi');
    
    #######################################################################
    # BIG assumption ... PAB is on the same directory server.
    #
    # If the directory server is somewhere else, clean up 
    # this connection and reconnect to the appropriate server
    #######################################################################
    if( $paburi =~ /ldap:\/\/.*?\/(.*)/){
       $ldapBaseDN = $1;
    }
    else {
       die "The directory entry contained no pabURI for $uid\n";
    }
    
    # Next, search for all the PAB entries for this user
    my $res = $ldap->search(base => $ldapBaseDN, scope => 'sub', filter => '(objectclass=*)');
    $res->code && die $res->error;
    
    # cycle through the PAB and build a HoHs
    foreach $ent ($res->entries) {
    
       $key = $ent->get_value('un');
       $key or next;
    
       @obj = $ent->get_value('objectclass');
       foreach $val (@obj){ 
          $val = lc $val; 
          if( ($val eq 'pabgroup') || ($val eq 'pabperson') ) 
          {
              $val =~ s/^\'|\'$//;
              $entry{$key}{'objectclass'} = $val;
          }
       }
    
       @mem = $ent->get_value('memberofpabgroup');
       foreach $val (@mem){
          push @{ $entry{$key}{'memberofpabgroup'} }, $val;
          push @{ $entry{$val}{'members'} }, $key;
       }
     
       foreach $i ( keys %sun2zimPerson ){
          $val = $ent->get_value($i);
          $val  =~ s/\$/"\n"/eg;
          $val  =~ s/\\(..)/pack'H*',$1/eg;
          $entry{$key}{$i} = $val;
       }    
    }
    $ldap->unbind;
    
    open OUT, "> $output" or die $!;
    foreach $key ( keys %entry ){
       $line = '';
       # if it isn't a person or group skip it
       if( $entry{$key}{'objectclass'} eq 'pabgroup' ){
    
           $entry{$key}{'cn'} or next; # if no group name, skip it.
           $entry{$key}{'cn'} =~ s/\"/\\"/sg;
           $entry{$key}{'cn'} =~ s/^\'|\'$//;
           $entry{$key}{'cn'} =~ s/^\s+|\s+$//;
    
           print OUT "cct type group nickname \"$entry{$key}{'cn'}\" fileAs \"8:$entry{$key}{'cn'}\" ";
    
           $line = '';
           # this pulls the list members
           for $i ( @{ $entry{$key}{'members'} } ){
             if($entry{$i}{'cn'})
             {
                $_ = $entry{$i}{'cn'};
                s/\"/\\"/sg;
                s/^\'|\'$//; # no leading or trailing single quotes
                s/^\s+|\s+$//; # no leading or trailing spaces
                $line .= "$_ ";
             }
    
             if( $entry{$i}{'mail'} =~ /\@/ ) # buggy if it doesn't contain an @
             {
                $entry{$key}{$i} =~ s/^\s+|\s+$//;
                $line .= "<$entry{$i}{'mail'}>,";
             }
           }
           $line =~ s/^(.*?).$/dlist \"$1\"/; # drop last comma and adds the list command
           print OUT $line . "\n";
       }
       elsif( $entry{$key}{'objectclass'} eq 'pabperson' ){
           print OUT "cct ";
           for $i (keys %sun2zimPerson){
              if( $entry{$key}{$i} )
              {
                 $entry{$key}{$i} =~ s/\"/\\"/sg;
                 $entry{$key}{$i} =~ s/^\'|\'$//;
                 $entry{$key}{$i} =~ s/^\s+|\s+$//;
                 if($entry{$key}{$i} =~ /\n|\s|,/s)
                 {
                    $entry{$key}{$i} =~ s/^(.*)$/\"$1\"/msg;
                 }
                 $entry{$key}{$i} =~ s/\n/\\n/msg;
                 print OUT "$sun2zimPerson{$i} $entry{$key}{$i} ";
              }
    
           }
           print OUT "\n";
       }
    }
    
    print "Now run:\n  zmmailbox -z -m uid\@domain -f $output\n" . 
          "like, " .
          "  zmmailbox -z -m jimnorton\@host.com -f $output\n";

  7. #7
    Join Date
    Apr 2012
    Posts
    4
    Rep Power
    3

    Default

    Thx

    I'll test it and let you know how it goes.

    BR.

  8. #8
    Join Date
    Apr 2012
    Posts
    4
    Rep Power
    3

    Default

    It works just fine.

    Now I guess I have to try to adapt it to bulk export users' PABs from Sunone Directory Server and import them into zimbra.

    Thx a lot.

  9. #9
    Join Date
    Apr 2012
    Posts
    4
    Rep Power
    3

    Default

    Hi fowler,

    Just a FYI.
    Since we are using hosted domains in JES, I had to do a minor change in your script to do the search based on the mail attribute, or else it was giving a "More than one result returned" error when it finds a username that exists in more than one domain:
    Code:
    my $uid = shift or die "$0 <mail>\n";
    instead of
    my $uid = shift or die "$0 <uid>\n";
    and
    Code:
    my $res = $ldap->search( base => $ldapBaseDN, scope => 'sub', filter => '(mail=' . $uid . ')', attrs => ['paburi']);
    instead of
    my $res = $ldap->search( base => $ldapBaseDN, scope => 'sub', filter => '(uid=' . $uid . ')', attrs => ['paburi']);
    Everything else worked like a charm.

    Thanks again
    Cheers

  10. #10
    Join Date
    Jan 2009
    Location
    Fresno
    Posts
    31
    Rep Power
    6

    Default

    Very cool. Glad you could make use of it!

Similar Threads

  1. LDAP Cannot bind on migration to new server
    By neekster in forum Migration
    Replies: 23
    Last Post: 03-09-2009, 02:08 AM
  2. upgrading from 5.0.4 to 5.0.5 opensource
    By smoke in forum Installation
    Replies: 4
    Last Post: 10-19-2008, 10:38 AM
  3. Replies: 8
    Last Post: 08-07-2008, 05:18 AM
  4. Replies: 2
    Last Post: 02-12-2008, 10:55 AM
  5. Zimbra Install Problem - getDirectContext
    By bsimzer in forum Installation
    Replies: 27
    Last Post: 07-19-2007, 10:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •