Bulk Provisioning: Difference between revisions
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
#!/usr/bin/perl | #!/usr/bin/perl | ||
# Lookup the valid COS (Class of Service) ID in the interface | # Lookup the valid COS (Class of Service) ID in the interface | ||
# TODO: Find a way to map this automatically from the name rather than ID | # TODO: Find a way to map this automatically from the name rather than ID | ||
my $cosid = "fd7ec8fc-069f-1111-1111-1111"; | my $cosid = "fd7ec8fc-069f-1111-1111-1111"; | ||
while (<>) { | while (<>) { | ||
chomp; | chomp; | ||
# CHANGE ME: To the actual fields you use in your CSV file | # CHANGE ME: To the actual fields you use in your CSV file | ||
my ($email, $password, $first, $last) = split(/\t/, $_, 4); | my ($email, $password, $first, $last) = split(/\t/, $_, 4); | ||
my ($uid, $domain) = split(/@/, $email, 2); | my ($uid, $domain) = split(/@/, $email, 2); | ||
print qq{ca $uid\@$domain $password\n}; | print qq{ca $uid\@$domain $password\n}; | ||
print qq{ma $uid\@$domain zimbraCOSid "$cosid"\n}; | print qq{ma $uid\@$domain zimbraCOSid "$cosid"\n}; |
Revision as of 01:59, 4 April 2006
Bulk Create
Following is a simple perl script to take a CSV file and turn it into the correct zmprov commands
#!/usr/bin/perl # Lookup the valid COS (Class of Service) ID in the interface # TODO: Find a way to map this automatically from the name rather than ID my $cosid = "fd7ec8fc-069f-1111-1111-1111"; while (<>) { chomp; # CHANGE ME: To the actual fields you use in your CSV file my ($email, $password, $first, $last) = split(/\t/, $_, 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}; }
The above is only a starting place, you will need to change other options (eg: the zimbraPasswordMustChange is an example only) and of course how you create and split the input data.
Also, some CSV files may contain quotes you want to remove.
To execute use:
perl csv2zmprov < mydata.csv > mydata.zmp zmprov < mydata.zmp
Enjoy