Results 1 to 4 of 4

Thread: Importing accounts from csv file for account provisioning

  1. #1
    eloelo22 is offline Starter Member
    Join Date
    Sep 2013
    Posts
    2
    Rep Power
    1

    Default Importing accounts from csv file for account provisioning

    HI everyone,

    i need some help i saw the instruction on wiki on how to do bulk account provisioning. i communicate with the server trough putty ssh now my problem is since i use putty how can i read the csv from my laptop or should i upload it to the server before running the script if true is there anyone who can show a tutorial on how i can upload the csv file to the server

  2. #2
    phoenix is online now Zimbra Consultant & Moderator
    Join Date
    Sep 2005
    Location
    Vannes, France
    Posts
    23,201
    Rep Power
    56

    Default

    Quote Originally Posted by eloelo22 View Post
    i need some help i saw the instruction on wiki on how to do bulk account provisioning. i communicate with the server trough putty ssh now my problem is since i use putty how can i read the csv from my laptop or should i upload it to the server before running the script if true is there anyone who can show a tutorial on how i can upload the csv file to the server
    You obviously need the files on the server, search the internet for details on how to copy files to a server with ssh or scp.
    Regards


    Bill


    Acompli: A new adventure for Co-Founder KevinH.

  3. #3
    eloelo22 is offline Starter Member
    Join Date
    Sep 2013
    Posts
    2
    Rep Power
    1

    Default

    thanks i already uploaded the file i saw this

    #!/usr/bin/perl

    # Lookup the valid COS (Class of Service) ID in the interface or like this
    my $cosid = `su - zimbra -c 'zmprov gc Default |grep zimbraId:'`;
    $cosid =~ s/zimbraId:\s*|\s*$//g;

    while (<>) {
    chomp;

    # CHANGE ME: To the actual fields you use in your CSV file
    my ($email, $password, $first, $last) = split(/\,/, $_, 4);

    my ($uid, $domain) = split(/@/, $email, 2);

    print qq{ca $uid\@$domain $password\n};
    print qq{ma $uid\@$domain zimbraCOSid "$cosid"\n};
    print qq{ma $uid\@$domain givenName "$first"\n};
    print qq{ma $uid\@$domain sn "$last"\n};
    print qq{ma $uid\@$domain cn "$uid"\n};
    print qq{ma $uid\@$domain displayName "$first $last"\n};
    print qq{ma $uid\@$domain zimbraPasswordMustChange TRUE\n};
    print qq{\n};
    }

    but i am a bit confused sorry i am newbie i cant see anywhere in the line where it reads the csv file i uploaded

  4. #4
    ppearl's Avatar
    ppearl is offline Zimbra Employee
    Join Date
    Jul 2007
    Location
    US
    Posts
    61
    Rep Power
    7

    Default

    This is a Perl question. The short answer is that the "<>" in while(<>) { ... } is where it is read, assuming you provided the name of the file as either an argument to the perl script, or via a '<' or '|' on the command line. For example:
    zimbra$ perl myperlprogram.pl myfile.csv

    See the perl manual for lots of info: perlop - perldoc.perl.org
    or maybe perlopentut - perldoc.perl.org

    Sorry if that's too much info.

    Now, when it comes to provisioning an account you will probably find it faster to specify the command all at once instead of N commands.

    So instead of
    ca $user $pass
    ma $uid $attr $val
    ma $uid $attr $val
    ...

    Do it on one line:
    ca $user $pass $attr1 $val1 $attr2 $val2 ...

    More concretely (no need to specify the default CosID, just non-default):
    ca phil@dom.local badpassword zimbraCOSid $nonDefaultCosID displayName "Phil Pearl" zimbraPasswordMustChange TRUE ...

    Of course any $variables with quotes or special characters need to always be handled appropriately.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Sync openLDAP / Zimbra LDAP after account provisioning
    By gerardsd in forum Administrators
    Replies: 4
    Last Post: 04-01-2014, 08:17 PM
  2. Replies: 0
    Last Post: 03-21-2013, 03:15 AM
  3. CSV Account Provisioning
    By f0rd42 in forum Administrators
    Replies: 4
    Last Post: 03-20-2010, 02:01 PM
  4. Account provisioning logs
    By ple in forum Administrators
    Replies: 0
    Last Post: 05-15-2009, 08:23 AM
  5. Zimbra + Samba bulk account provisioning
    By mficara in forum Administrators
    Replies: 3
    Last Post: 06-14-2007, 07:33 PM

Tags for this Thread

Posting Permissions

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