This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
46
Installation and Upgrades / Re: Bulk User import for Zentyal 4 with add to existing Group function
« on: November 28, 2014, 02:46:25 pm »
Thanks for answer!
here is result:
and it couldn't be problem with permissions, cause i try to do it from root user.
maybe i have to install some extra perl modules?
here is result:
Code: [Select]
root@zentyal:~# cat results
#!/usr/bin/perl
use strict;
use warnings;
use EBox;
use EBox::Samba;
use EBox::Samba::User;
use EBox::Samba::Group;
EBox::init();
my $parent = EBox::Samba::User->defaultContainer();
open (my $USERS, 'users.csv');
while (my $line = <$USERS>) {
chomp ($line);
if (substr($line, 0, 1) ne '#') {
my ($group, $username, $firstname, $lastname, $password, $description) = split(',', $line);
my %user;
$user{parent} = $parent;
$user{group} = $group;
$user{samAccountName} = $username;
$user{givenName} = $firstname;
$user{sn} = $lastname;
$user{password} = $password;
$user{description} = $description; #optional
my $nuser = EBox::Samba::User->create(%user);
if ($nuser->exists()) {
print "$username added\n";
$nuser->addGroup(new EBox::Samba::Group(samAccountName => $user{group}));
if ($nuser->exists()) {
print "$username added to $group\n";
}
}
}
}
close ($USERS);
1;
#group(existing),username,firstname,lastname,password,description(optional)
common,test1,testName1,testLast1,sdfsdf,blahblah
common,test2,testName2,testLast2,sdfggg,Hehe
total 80
drwx------ 9 root root 4096 Nov 28 16:42 .
drwxr-xr-x 23 root root 4096 Nov 27 12:44 ..
-rw-r--r-- 1 root root 1003 Nov 27 14:36 add_user.pl
-rw------- 1 root root 607 Nov 27 18:11 .bash_history
-rw-r--r-- 1 root root 3106 Feb 20 2014 .bashrc
drwx------ 3 root root 4096 Nov 27 12:54 .cache
drwx------ 4 root root 4096 Nov 27 15:51 .config
drwx------ 3 root root 4096 Nov 27 12:31 .dbus
drwx------ 2 root root 4096 Nov 27 12:31 .gconf
drwx------ 3 root root 4096 Nov 27 12:31 .gnome2
drwx------ 2 root root 4096 Nov 27 12:31 .gnome2_private
drwx------ 3 root root 4096 Nov 27 12:54 .local
-rw-r--r-- 1 root root 140 Feb 20 2014 .profile
-rw-r--r-- 1 root root 1175 Nov 28 16:42 results
-rw-r--r-- 1 root root 72 Nov 27 12:54 .selected_editor
-rw-r--r-- 1 root root 172 Nov 27 14:02 users.csv
and it couldn't be problem with permissions, cause i try to do it from root user.
maybe i have to install some extra perl modules?
47
Installation and Upgrades / Re: Bulk User import for Zentyal 4 with add to existing Group function
« on: November 27, 2014, 12:10:22 pm »
Hello!
i've tried your script - and have next error:
root@zentyal:~# perl users.csv
Can't locate object method "blahblah" via package "common" (perhaps you forgot to load "common"?) at users.csv line 2.
my mistake...
actual error is the same:
users.csv is:
root@zentyal:~# perl users.csv
Can't locate object method "blahblah" via package "common" (perhaps you forgot to load "common"?) at users.csv line 2.
my mistake...
actual error is the same:
Code: [Select]
root@zentyal:~# perl add_user.pl
readline() on closed filehandle $USERS at add_user.pl line 17.
users.csv is:
Code: [Select]
root@zentyal:~# cat users.csv
#group(existing),username,firstname,lastname,password,description(optional)
common,test1,testName1,testLast1,sdfsdf,blahblah
common,test2,testName2,testLast2,sdfggg,Hehe