From 85f7c7127f6542850282a3f86451e8e4e16736c6 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 4 Jul 2007 16:17:48 +0000 Subject: r23706: Add a script to create domainusers,-groups and -aliases. This is done via rpc client. The main purpose is to be able to fill a domain controller with a large number of users / groups easily. A the object names are built as where number ranges from a given start number counting up until a given number of objects has been created. In a next step, I will submit scripts to add (many) users to a group and to add a user to (many) groups. Michael (This used to be commit 8b81fbb7d998eda65978a772f2194b4a3de467f9) --- examples/scripts/users_and_groups/createdomobj.pl | 155 ++++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100755 examples/scripts/users_and_groups/createdomobj.pl (limited to 'examples/scripts/users_and_groups') diff --git a/examples/scripts/users_and_groups/createdomobj.pl b/examples/scripts/users_and_groups/createdomobj.pl new file mode 100755 index 0000000000..4bcfb8edf3 --- /dev/null +++ b/examples/scripts/users_and_groups/createdomobj.pl @@ -0,0 +1,155 @@ +#!/usr/bin/perl + +# +# createdomobj.pl +# +# create single or continuously numbered domain +# users/groups/aliases via rpc +# +# Copyright (C) Michael Adam 2007 +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2 of the License, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 675 +# Mass Ave, Cambridge, MA 02139, USA. +# + +# +# WARNING: This script is still rather crude. +# + +use strict; +use Getopt::Std; + + +my $target_type = "group"; # what type of object to create +my $rpc_cmd = "createdom".$target_type; +my $rpccli_cmd = "rpcclient"; + +# defaults: + +my $server; +my $num_targets = 1; +my $startnum; # if empty, don't add numbers to prefix +my $prefix = $target_type; # name-prefix +my $path; # path to rpcclient command +my $rpccli_path = $rpccli_cmd; +my $creds; + +sub usage { + print "USAGE: $0 [-h] -S server -U user\%pass [-p prefix] \\\n" + . "\t[-t {alias|group|user}] [-s startnum] [-n numobjs] [-P path] \n"; +} + +# parse commandline: + +my %options = (); +getopts("U:t:S:s:n:p:P:h", \%options); + +if (exists($options{h})) { + usage(); + exit 0; +} + +if (exists($options{t})) { + $target_type = $options{t}; + if ($target_type !~ /^(alias|user|group)$/) { + print "ERROR: invalid target type given\n"; + usage(); + exit 1; + } + $rpc_cmd = "createdom".$target_type; +} + +if (exists($options{U})) { + $creds = "-U $options{U}"; + if ($creds !~ '%') { + print "ERROR: you need to specify credentials in the form -U user\%pass\n"; + usage(); + exit 1; + } +} +else { + print "ERROR: mandatory argument '-U' missing\n"; + usage(); + exit 1; +} + +if (exists($options{S})) { + $server = $options{S}; +} +else { + print "ERROR: madatory argument '-S' missing\n"; + usage(); + exit 1; +} + +if (exists($options{s})) { + $startnum = $options{s}; +} + +if (exists($options{n})) { + $num_targets = $options{n}; +} + +if (exists($options{p})) { + $prefix = $options{p}; +} + +if (exists($options{P})) { + $path = $options{p}; + $rpccli_path = "$path/$rpccli_cmd"; +} + +if (@ARGV) { + print "ERROR: junk on the command line ('" . join(" ", @ARGV) . "')...\n"; + usage(); + exit 1; +} + +# rpc open/close functions: + +sub open_rpc_pipe { + print "opening rpc pipe\n"; + open(IPC, "| $rpccli_cmd $server $creds -d0") or + die "error opening rpc pipe."; +} + +sub close_rpc_pipe { + print "closing rpc pipe\n"; + close(IPC); +} + +# main: + +open_rpc_pipe(); + +if ("x$startnum" eq "x") { + my $target_name = $prefix; + print "creating $target_type $target_name\n"; + print IPC "$rpc_cmd $target_name\n"; +} +else { + for (my $num = 1; $num <= $num_targets; ++$num) { + my $target_name = sprintf "%s%.05d", $prefix, $startnum + $num - 1; + print "creating $target_type $target_name\n"; + print IPC "$rpc_cmd $target_name\n"; + if (($num) % 500 == 0) { + printf("500 ".$target_type."s created\n"); + close_rpc_pipe(); + sleep 2; + open_rpc_pipe(); + } + } +} +close_rpc_pipe(); + -- cgit From 4b1fbd17c4de11e9da610e3ecd83a975a8e64df2 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 4 Jul 2007 23:21:51 +0000 Subject: r23711: Refactor the actual creation of object into its own small function. Michael (This used to be commit 26349c0b173e8baf6fa43deb39cb2bfdb31bf18e) --- examples/scripts/users_and_groups/createdomobj.pl | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'examples/scripts/users_and_groups') diff --git a/examples/scripts/users_and_groups/createdomobj.pl b/examples/scripts/users_and_groups/createdomobj.pl index 4bcfb8edf3..6568b21664 100755 --- a/examples/scripts/users_and_groups/createdomobj.pl +++ b/examples/scripts/users_and_groups/createdomobj.pl @@ -116,7 +116,7 @@ if (@ARGV) { exit 1; } -# rpc open/close functions: +# utility functions: sub open_rpc_pipe { print "opening rpc pipe\n"; @@ -129,20 +129,22 @@ sub close_rpc_pipe { close(IPC); } +sub do_create { + my $target_name = shift; + print "creating $target_type $target_name\n"; + print IPC "$rpc_cmd $target_name\n"; +} + # main: open_rpc_pipe(); if ("x$startnum" eq "x") { - my $target_name = $prefix; - print "creating $target_type $target_name\n"; - print IPC "$rpc_cmd $target_name\n"; + do_create($prefix); } else { for (my $num = 1; $num <= $num_targets; ++$num) { - my $target_name = sprintf "%s%.05d", $prefix, $startnum + $num - 1; - print "creating $target_type $target_name\n"; - print IPC "$rpc_cmd $target_name\n"; + do_create(sprintf "%s%.05d", $prefix, $startnum + $num - 1); if (($num) % 500 == 0) { printf("500 ".$target_type."s created\n"); close_rpc_pipe(); @@ -151,5 +153,6 @@ else { } } } + close_rpc_pipe(); -- cgit From 459d01489fcebfe923328409d8ad5750c218cb18 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 5 Jul 2007 00:07:40 +0000 Subject: r23712: This script allows for adding lists of users (or other objects) to lists of groups (or aliases). Useful for creating large test scenarios. Michael (This used to be commit 0c03c78af8f62ece2965e0f5a16c001aad61c8fa) --- examples/scripts/users_and_groups/addusertogroups.pl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 examples/scripts/users_and_groups/addusertogroups.pl (limited to 'examples/scripts/users_and_groups') diff --git a/examples/scripts/users_and_groups/addusertogroups.pl b/examples/scripts/users_and_groups/addusertogroups.pl new file mode 100755 index 0000000000..f3e1bee977 --- /dev/null +++ b/examples/scripts/users_and_groups/addusertogroups.pl @@ -0,0 +1,17 @@ +#!/usr/bin/perl + +use strict; + +my $dc = "192.168.45.44"; +my $adminuser = "administrator"; +my $adminpw = "geheim"; +my $maxgroups = 5000; +my $startgroup = 0; +my $rpccli_cmd = "/usr/bin/rpcclient"; +my $testuser = "testgroups"; + +for (my $num = $startgroup; $num <= $maxgroups; ++$num) { + my $group = sprintf "%s%.05d", "group", $num; + print "adding user $testuser to group $group\n"; + system("net rpc -I $dc -U$adminuser\%$adminpw group addmem $group $testuser"); +} -- cgit From 1d95e049bbc23cc56c573c0c249d075da0ac219d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 5 Jul 2007 00:11:07 +0000 Subject: r23713: Oops accidentially checked in the wrong file - sorry! Michael (This used to be commit ae23e6d04b8551e66b77995994a0c50cd880ea32) --- examples/scripts/users_and_groups/addusertogroups.pl | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100755 examples/scripts/users_and_groups/addusertogroups.pl (limited to 'examples/scripts/users_and_groups') diff --git a/examples/scripts/users_and_groups/addusertogroups.pl b/examples/scripts/users_and_groups/addusertogroups.pl deleted file mode 100755 index f3e1bee977..0000000000 --- a/examples/scripts/users_and_groups/addusertogroups.pl +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/perl - -use strict; - -my $dc = "192.168.45.44"; -my $adminuser = "administrator"; -my $adminpw = "geheim"; -my $maxgroups = 5000; -my $startgroup = 0; -my $rpccli_cmd = "/usr/bin/rpcclient"; -my $testuser = "testgroups"; - -for (my $num = $startgroup; $num <= $maxgroups; ++$num) { - my $group = sprintf "%s%.05d", "group", $num; - print "adding user $testuser to group $group\n"; - system("net rpc -I $dc -U$adminuser\%$adminpw group addmem $group $testuser"); -} -- cgit From c799a1e9803b5b2f88d6872d8850bbebdc854fc1 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 5 Jul 2007 00:12:24 +0000 Subject: r23714: but now: This script allows for adding lists of users (or other objects) to lists of groups (or aliases). Useful for creating large test scenarios. Michael (This used to be commit b3e5082e105f6eaeed51e9a42d525d811e7155ee) --- .../scripts/users_and_groups/adduserstogroups.pl | 167 +++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100755 examples/scripts/users_and_groups/adduserstogroups.pl (limited to 'examples/scripts/users_and_groups') diff --git a/examples/scripts/users_and_groups/adduserstogroups.pl b/examples/scripts/users_and_groups/adduserstogroups.pl new file mode 100755 index 0000000000..335dad00aa --- /dev/null +++ b/examples/scripts/users_and_groups/adduserstogroups.pl @@ -0,0 +1,167 @@ +#!/usr/bin/perl + +# +# adduserstogroups.pl +# +# add single or continuously numbered domain users +# to a given single group or list of groups +# +# Copyright (C) Michael Adam 2007 +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2 of the License, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 675 +# Mass Ave, Cambridge, MA 02139, USA. +# + +# +# WARNING: This script is still rather crude. +# + +use strict; +use Getopt::Std; + +my $net_cmd = "net"; + +# defaults: + +my $server; +my $num_members = 1; +my $startmem; # if empty, don't add numbers to member prefix +my $member_prefix; # name prefix for member +my $num_groups = 1; +my $startgroup; # if empty, don't add numbers to group prefix +my $group_prefix; # name prefix for group +my $path; # path to rpcclient command +my $net_path = $net_cmd; +my $creds; + +sub usage { + print "USAGE: $0 [-h] -S server -U user\%pass \\\n" + . "\t-m member [-s startmem] [-n nummem] \\\n" + . "\t-g group [-G stargroup] [-N numgroups] \\\n" + . "\t[-P path]\n"; +} + +# parse commandline: + +my %options = (); +getopts("U:S:m:s:n:g:G:N:P:h", \%options); + +if (exists($options{h})) { + usage(); + exit 0; +} + +if (exists($options{g})) { + $group_prefix = $options{g}; +} +else { + print "ERROR: mandatory argument '-g' missing\n"; + usage(); + exit 1; +} + +if (exists($options{U})) { + $creds = "-U $options{U}"; + if ($creds !~ '%') { + print "ERROR: you need to specify credentials in the form -U user\%pass\n"; + usage(); + exit 1; + } +} +else { + print "ERROR: mandatory argument '-U' missing\n"; + usage(); + exit 1; +} + +if (exists($options{S})) { + $server = $options{S}; +} +else { + print "ERROR: madatory argument '-S' missing\n"; + usage(); + exit 1; +} + +if (exists($options{s})) { + $startmem = $options{s}; +} + +if (exists($options{n})) { + $num_members = $options{n}; +} + +if (exists($options{m})) { + $member_prefix = $options{m}; +} +else { + print "ERROR: mandatory argument '-m' missing\n"; + usage(); + exit 1; +} + +if (exists($options{G})) { + $startgroup = $options{G}; +} + +if (exists($options{N})) { + $num_groups = $options{N}; +} + +if (exists($options{P})) { + $path = $options{p}; + $net_path = "$path/$net_cmd"; +} + +if (@ARGV) { + print "ERROR: junk on the command line ('" . join(" ", @ARGV) . "')...\n"; + usage(); + exit 1; +} + +# utility functions: + +sub do_add { + my $member_name = shift; + my $group_name = shift; + print "adding member $member_name to group $group_name\n"; + system("$net_path rpc -I $server ".$creds." group addmem $group_name $member_name"); +} + +sub add_group_loop { + my $member_name = shift; + + if ("x$startgroup" eq "x") { + do_add($member_name, $group_prefix); + } + else { + for (my $groupnum = 1; $groupnum <= $num_groups; ++$groupnum) { + do_add($member_name, + sprintf("%s%.05d", $group_prefix, $startgroup + $groupnum - 1)); + } + } +} + + +# main: + +if ("x$startmem" eq "x") { + add_group_loop($member_prefix); +} +else { + for (my $memnum = 1; $memnum <= $num_members; ++$memnum) { + add_group_loop(sprintf("%s%.05d", $member_prefix, $startmem + $memnum - 1)); + } +} + -- cgit From 2a9b4da0fa00d4ada504f49fafcadab7b0094331 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:46:27 +0000 Subject: r23780: Find and fix more GPL2 -> GPL3. Jeremy. (This used to be commit c2f7ab1c175ecff0cf44d0bbc4763ba9f7d7803f) --- examples/scripts/users_and_groups/adduserstogroups.pl | 2 +- examples/scripts/users_and_groups/createdomobj.pl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'examples/scripts/users_and_groups') diff --git a/examples/scripts/users_and_groups/adduserstogroups.pl b/examples/scripts/users_and_groups/adduserstogroups.pl index 335dad00aa..52a7d01703 100755 --- a/examples/scripts/users_and_groups/adduserstogroups.pl +++ b/examples/scripts/users_and_groups/adduserstogroups.pl @@ -10,7 +10,7 @@ # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free -# Software Foundation; either version 2 of the License, or (at your option) +# Software Foundation; either version 3 of the License, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but WITHOUT diff --git a/examples/scripts/users_and_groups/createdomobj.pl b/examples/scripts/users_and_groups/createdomobj.pl index 6568b21664..36e0c0f9fd 100755 --- a/examples/scripts/users_and_groups/createdomobj.pl +++ b/examples/scripts/users_and_groups/createdomobj.pl @@ -10,7 +10,7 @@ # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free -# Software Foundation; either version 2 of the License, or (at your option) +# Software Foundation; either version 3 of the License, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but WITHOUT -- cgit From 153cfb9c83534b09f15cc16205d7adb19b394928 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 05:23:25 +0000 Subject: r23801: The FSF has moved around a lot. This fixes their Mass Ave address. (This used to be commit 87c91e4362c51819032bfbebbb273c52e203b227) --- examples/scripts/users_and_groups/adduserstogroups.pl | 3 +-- examples/scripts/users_and_groups/createdomobj.pl | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'examples/scripts/users_and_groups') diff --git a/examples/scripts/users_and_groups/adduserstogroups.pl b/examples/scripts/users_and_groups/adduserstogroups.pl index 52a7d01703..17ca5bd842 100755 --- a/examples/scripts/users_and_groups/adduserstogroups.pl +++ b/examples/scripts/users_and_groups/adduserstogroups.pl @@ -19,8 +19,7 @@ # more details. # # You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 675 -# Mass Ave, Cambridge, MA 02139, USA. +# this program; if not, see . # # diff --git a/examples/scripts/users_and_groups/createdomobj.pl b/examples/scripts/users_and_groups/createdomobj.pl index 36e0c0f9fd..60f34b84f2 100755 --- a/examples/scripts/users_and_groups/createdomobj.pl +++ b/examples/scripts/users_and_groups/createdomobj.pl @@ -19,8 +19,7 @@ # more details. # # You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 675 -# Mass Ave, Cambridge, MA 02139, USA. +# this program; if not, see . # # -- cgit From e5a951325a6cac8567af3a66de6d2df577508ae4 Mon Sep 17 00:00:00 2001 From: "Gerald (Jerry) Carter" Date: Wed, 10 Oct 2007 15:34:30 -0500 Subject: [GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch. (This used to be commit 5c6c8e1fe93f340005110a7833946191659d88ab) --- .../scripts/users_and_groups/adduserstogroups.pl | 166 --------------------- examples/scripts/users_and_groups/createdomobj.pl | 157 ------------------- 2 files changed, 323 deletions(-) delete mode 100755 examples/scripts/users_and_groups/adduserstogroups.pl delete mode 100755 examples/scripts/users_and_groups/createdomobj.pl (limited to 'examples/scripts/users_and_groups') diff --git a/examples/scripts/users_and_groups/adduserstogroups.pl b/examples/scripts/users_and_groups/adduserstogroups.pl deleted file mode 100755 index 17ca5bd842..0000000000 --- a/examples/scripts/users_and_groups/adduserstogroups.pl +++ /dev/null @@ -1,166 +0,0 @@ -#!/usr/bin/perl - -# -# adduserstogroups.pl -# -# add single or continuously numbered domain users -# to a given single group or list of groups -# -# Copyright (C) Michael Adam 2007 -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free -# Software Foundation; either version 3 of the License, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, see . -# - -# -# WARNING: This script is still rather crude. -# - -use strict; -use Getopt::Std; - -my $net_cmd = "net"; - -# defaults: - -my $server; -my $num_members = 1; -my $startmem; # if empty, don't add numbers to member prefix -my $member_prefix; # name prefix for member -my $num_groups = 1; -my $startgroup; # if empty, don't add numbers to group prefix -my $group_prefix; # name prefix for group -my $path; # path to rpcclient command -my $net_path = $net_cmd; -my $creds; - -sub usage { - print "USAGE: $0 [-h] -S server -U user\%pass \\\n" - . "\t-m member [-s startmem] [-n nummem] \\\n" - . "\t-g group [-G stargroup] [-N numgroups] \\\n" - . "\t[-P path]\n"; -} - -# parse commandline: - -my %options = (); -getopts("U:S:m:s:n:g:G:N:P:h", \%options); - -if (exists($options{h})) { - usage(); - exit 0; -} - -if (exists($options{g})) { - $group_prefix = $options{g}; -} -else { - print "ERROR: mandatory argument '-g' missing\n"; - usage(); - exit 1; -} - -if (exists($options{U})) { - $creds = "-U $options{U}"; - if ($creds !~ '%') { - print "ERROR: you need to specify credentials in the form -U user\%pass\n"; - usage(); - exit 1; - } -} -else { - print "ERROR: mandatory argument '-U' missing\n"; - usage(); - exit 1; -} - -if (exists($options{S})) { - $server = $options{S}; -} -else { - print "ERROR: madatory argument '-S' missing\n"; - usage(); - exit 1; -} - -if (exists($options{s})) { - $startmem = $options{s}; -} - -if (exists($options{n})) { - $num_members = $options{n}; -} - -if (exists($options{m})) { - $member_prefix = $options{m}; -} -else { - print "ERROR: mandatory argument '-m' missing\n"; - usage(); - exit 1; -} - -if (exists($options{G})) { - $startgroup = $options{G}; -} - -if (exists($options{N})) { - $num_groups = $options{N}; -} - -if (exists($options{P})) { - $path = $options{p}; - $net_path = "$path/$net_cmd"; -} - -if (@ARGV) { - print "ERROR: junk on the command line ('" . join(" ", @ARGV) . "')...\n"; - usage(); - exit 1; -} - -# utility functions: - -sub do_add { - my $member_name = shift; - my $group_name = shift; - print "adding member $member_name to group $group_name\n"; - system("$net_path rpc -I $server ".$creds." group addmem $group_name $member_name"); -} - -sub add_group_loop { - my $member_name = shift; - - if ("x$startgroup" eq "x") { - do_add($member_name, $group_prefix); - } - else { - for (my $groupnum = 1; $groupnum <= $num_groups; ++$groupnum) { - do_add($member_name, - sprintf("%s%.05d", $group_prefix, $startgroup + $groupnum - 1)); - } - } -} - - -# main: - -if ("x$startmem" eq "x") { - add_group_loop($member_prefix); -} -else { - for (my $memnum = 1; $memnum <= $num_members; ++$memnum) { - add_group_loop(sprintf("%s%.05d", $member_prefix, $startmem + $memnum - 1)); - } -} - diff --git a/examples/scripts/users_and_groups/createdomobj.pl b/examples/scripts/users_and_groups/createdomobj.pl deleted file mode 100755 index 60f34b84f2..0000000000 --- a/examples/scripts/users_and_groups/createdomobj.pl +++ /dev/null @@ -1,157 +0,0 @@ -#!/usr/bin/perl - -# -# createdomobj.pl -# -# create single or continuously numbered domain -# users/groups/aliases via rpc -# -# Copyright (C) Michael Adam 2007 -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free -# Software Foundation; either version 3 of the License, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, see . -# - -# -# WARNING: This script is still rather crude. -# - -use strict; -use Getopt::Std; - - -my $target_type = "group"; # what type of object to create -my $rpc_cmd = "createdom".$target_type; -my $rpccli_cmd = "rpcclient"; - -# defaults: - -my $server; -my $num_targets = 1; -my $startnum; # if empty, don't add numbers to prefix -my $prefix = $target_type; # name-prefix -my $path; # path to rpcclient command -my $rpccli_path = $rpccli_cmd; -my $creds; - -sub usage { - print "USAGE: $0 [-h] -S server -U user\%pass [-p prefix] \\\n" - . "\t[-t {alias|group|user}] [-s startnum] [-n numobjs] [-P path] \n"; -} - -# parse commandline: - -my %options = (); -getopts("U:t:S:s:n:p:P:h", \%options); - -if (exists($options{h})) { - usage(); - exit 0; -} - -if (exists($options{t})) { - $target_type = $options{t}; - if ($target_type !~ /^(alias|user|group)$/) { - print "ERROR: invalid target type given\n"; - usage(); - exit 1; - } - $rpc_cmd = "createdom".$target_type; -} - -if (exists($options{U})) { - $creds = "-U $options{U}"; - if ($creds !~ '%') { - print "ERROR: you need to specify credentials in the form -U user\%pass\n"; - usage(); - exit 1; - } -} -else { - print "ERROR: mandatory argument '-U' missing\n"; - usage(); - exit 1; -} - -if (exists($options{S})) { - $server = $options{S}; -} -else { - print "ERROR: madatory argument '-S' missing\n"; - usage(); - exit 1; -} - -if (exists($options{s})) { - $startnum = $options{s}; -} - -if (exists($options{n})) { - $num_targets = $options{n}; -} - -if (exists($options{p})) { - $prefix = $options{p}; -} - -if (exists($options{P})) { - $path = $options{p}; - $rpccli_path = "$path/$rpccli_cmd"; -} - -if (@ARGV) { - print "ERROR: junk on the command line ('" . join(" ", @ARGV) . "')...\n"; - usage(); - exit 1; -} - -# utility functions: - -sub open_rpc_pipe { - print "opening rpc pipe\n"; - open(IPC, "| $rpccli_cmd $server $creds -d0") or - die "error opening rpc pipe."; -} - -sub close_rpc_pipe { - print "closing rpc pipe\n"; - close(IPC); -} - -sub do_create { - my $target_name = shift; - print "creating $target_type $target_name\n"; - print IPC "$rpc_cmd $target_name\n"; -} - -# main: - -open_rpc_pipe(); - -if ("x$startnum" eq "x") { - do_create($prefix); -} -else { - for (my $num = 1; $num <= $num_targets; ++$num) { - do_create(sprintf "%s%.05d", $prefix, $startnum + $num - 1); - if (($num) % 500 == 0) { - printf("500 ".$target_type."s created\n"); - close_rpc_pipe(); - sleep 2; - open_rpc_pipe(); - } - } -} - -close_rpc_pipe(); - -- cgit From 67e79219dac4adbae437f46e144f2f09676d44bc Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 4 Jul 2007 16:17:48 +0000 Subject: r23706: Add a script to create domainusers,-groups and -aliases. This is done via rpc client. The main purpose is to be able to fill a domain controller with a large number of users / groups easily. A the object names are built as where number ranges from a given start number counting up until a given number of objects has been created. In a next step, I will submit scripts to add (many) users to a group and to add a user to (many) groups. Michael (cherry picked from commit 8b81fbb7d998eda65978a772f2194b4a3de467f9) (This used to be commit 79414f8bfa9cce1b4543b3cf5d6ea65651fc0769) --- examples/scripts/users_and_groups/createdomobj.pl | 155 ++++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100755 examples/scripts/users_and_groups/createdomobj.pl (limited to 'examples/scripts/users_and_groups') diff --git a/examples/scripts/users_and_groups/createdomobj.pl b/examples/scripts/users_and_groups/createdomobj.pl new file mode 100755 index 0000000000..4bcfb8edf3 --- /dev/null +++ b/examples/scripts/users_and_groups/createdomobj.pl @@ -0,0 +1,155 @@ +#!/usr/bin/perl + +# +# createdomobj.pl +# +# create single or continuously numbered domain +# users/groups/aliases via rpc +# +# Copyright (C) Michael Adam 2007 +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2 of the License, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 675 +# Mass Ave, Cambridge, MA 02139, USA. +# + +# +# WARNING: This script is still rather crude. +# + +use strict; +use Getopt::Std; + + +my $target_type = "group"; # what type of object to create +my $rpc_cmd = "createdom".$target_type; +my $rpccli_cmd = "rpcclient"; + +# defaults: + +my $server; +my $num_targets = 1; +my $startnum; # if empty, don't add numbers to prefix +my $prefix = $target_type; # name-prefix +my $path; # path to rpcclient command +my $rpccli_path = $rpccli_cmd; +my $creds; + +sub usage { + print "USAGE: $0 [-h] -S server -U user\%pass [-p prefix] \\\n" + . "\t[-t {alias|group|user}] [-s startnum] [-n numobjs] [-P path] \n"; +} + +# parse commandline: + +my %options = (); +getopts("U:t:S:s:n:p:P:h", \%options); + +if (exists($options{h})) { + usage(); + exit 0; +} + +if (exists($options{t})) { + $target_type = $options{t}; + if ($target_type !~ /^(alias|user|group)$/) { + print "ERROR: invalid target type given\n"; + usage(); + exit 1; + } + $rpc_cmd = "createdom".$target_type; +} + +if (exists($options{U})) { + $creds = "-U $options{U}"; + if ($creds !~ '%') { + print "ERROR: you need to specify credentials in the form -U user\%pass\n"; + usage(); + exit 1; + } +} +else { + print "ERROR: mandatory argument '-U' missing\n"; + usage(); + exit 1; +} + +if (exists($options{S})) { + $server = $options{S}; +} +else { + print "ERROR: madatory argument '-S' missing\n"; + usage(); + exit 1; +} + +if (exists($options{s})) { + $startnum = $options{s}; +} + +if (exists($options{n})) { + $num_targets = $options{n}; +} + +if (exists($options{p})) { + $prefix = $options{p}; +} + +if (exists($options{P})) { + $path = $options{p}; + $rpccli_path = "$path/$rpccli_cmd"; +} + +if (@ARGV) { + print "ERROR: junk on the command line ('" . join(" ", @ARGV) . "')...\n"; + usage(); + exit 1; +} + +# rpc open/close functions: + +sub open_rpc_pipe { + print "opening rpc pipe\n"; + open(IPC, "| $rpccli_cmd $server $creds -d0") or + die "error opening rpc pipe."; +} + +sub close_rpc_pipe { + print "closing rpc pipe\n"; + close(IPC); +} + +# main: + +open_rpc_pipe(); + +if ("x$startnum" eq "x") { + my $target_name = $prefix; + print "creating $target_type $target_name\n"; + print IPC "$rpc_cmd $target_name\n"; +} +else { + for (my $num = 1; $num <= $num_targets; ++$num) { + my $target_name = sprintf "%s%.05d", $prefix, $startnum + $num - 1; + print "creating $target_type $target_name\n"; + print IPC "$rpc_cmd $target_name\n"; + if (($num) % 500 == 0) { + printf("500 ".$target_type."s created\n"); + close_rpc_pipe(); + sleep 2; + open_rpc_pipe(); + } + } +} +close_rpc_pipe(); + -- cgit From cc4541def01bb29519bd1ddccde2a1e1fd32629f Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 4 Jul 2007 23:21:51 +0000 Subject: r23711: Refactor the actual creation of object into its own small function. Michael (cherry picked from commit 26349c0b173e8baf6fa43deb39cb2bfdb31bf18e) (This used to be commit 852570059c974bc6c06f893e4bf5e76674e4ec00) --- examples/scripts/users_and_groups/createdomobj.pl | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'examples/scripts/users_and_groups') diff --git a/examples/scripts/users_and_groups/createdomobj.pl b/examples/scripts/users_and_groups/createdomobj.pl index 4bcfb8edf3..6568b21664 100755 --- a/examples/scripts/users_and_groups/createdomobj.pl +++ b/examples/scripts/users_and_groups/createdomobj.pl @@ -116,7 +116,7 @@ if (@ARGV) { exit 1; } -# rpc open/close functions: +# utility functions: sub open_rpc_pipe { print "opening rpc pipe\n"; @@ -129,20 +129,22 @@ sub close_rpc_pipe { close(IPC); } +sub do_create { + my $target_name = shift; + print "creating $target_type $target_name\n"; + print IPC "$rpc_cmd $target_name\n"; +} + # main: open_rpc_pipe(); if ("x$startnum" eq "x") { - my $target_name = $prefix; - print "creating $target_type $target_name\n"; - print IPC "$rpc_cmd $target_name\n"; + do_create($prefix); } else { for (my $num = 1; $num <= $num_targets; ++$num) { - my $target_name = sprintf "%s%.05d", $prefix, $startnum + $num - 1; - print "creating $target_type $target_name\n"; - print IPC "$rpc_cmd $target_name\n"; + do_create(sprintf "%s%.05d", $prefix, $startnum + $num - 1); if (($num) % 500 == 0) { printf("500 ".$target_type."s created\n"); close_rpc_pipe(); @@ -151,5 +153,6 @@ else { } } } + close_rpc_pipe(); -- cgit From a11351542009c89cba3194068908d8ca3c13b9e8 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 5 Jul 2007 00:12:24 +0000 Subject: r23714: This script allows for adding lists of users (or other objects) to lists of groups (or aliases). Useful for creating large test scenarios. Michael (cherry picked from commit b3e5082e105f6eaeed51e9a42d525d811e7155ee) (This used to be commit 78a2344fe7ed53e9927e189fa4d465652731deab) --- .../scripts/users_and_groups/adduserstogroups.pl | 167 +++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100755 examples/scripts/users_and_groups/adduserstogroups.pl (limited to 'examples/scripts/users_and_groups') diff --git a/examples/scripts/users_and_groups/adduserstogroups.pl b/examples/scripts/users_and_groups/adduserstogroups.pl new file mode 100755 index 0000000000..335dad00aa --- /dev/null +++ b/examples/scripts/users_and_groups/adduserstogroups.pl @@ -0,0 +1,167 @@ +#!/usr/bin/perl + +# +# adduserstogroups.pl +# +# add single or continuously numbered domain users +# to a given single group or list of groups +# +# Copyright (C) Michael Adam 2007 +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2 of the License, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 675 +# Mass Ave, Cambridge, MA 02139, USA. +# + +# +# WARNING: This script is still rather crude. +# + +use strict; +use Getopt::Std; + +my $net_cmd = "net"; + +# defaults: + +my $server; +my $num_members = 1; +my $startmem; # if empty, don't add numbers to member prefix +my $member_prefix; # name prefix for member +my $num_groups = 1; +my $startgroup; # if empty, don't add numbers to group prefix +my $group_prefix; # name prefix for group +my $path; # path to rpcclient command +my $net_path = $net_cmd; +my $creds; + +sub usage { + print "USAGE: $0 [-h] -S server -U user\%pass \\\n" + . "\t-m member [-s startmem] [-n nummem] \\\n" + . "\t-g group [-G stargroup] [-N numgroups] \\\n" + . "\t[-P path]\n"; +} + +# parse commandline: + +my %options = (); +getopts("U:S:m:s:n:g:G:N:P:h", \%options); + +if (exists($options{h})) { + usage(); + exit 0; +} + +if (exists($options{g})) { + $group_prefix = $options{g}; +} +else { + print "ERROR: mandatory argument '-g' missing\n"; + usage(); + exit 1; +} + +if (exists($options{U})) { + $creds = "-U $options{U}"; + if ($creds !~ '%') { + print "ERROR: you need to specify credentials in the form -U user\%pass\n"; + usage(); + exit 1; + } +} +else { + print "ERROR: mandatory argument '-U' missing\n"; + usage(); + exit 1; +} + +if (exists($options{S})) { + $server = $options{S}; +} +else { + print "ERROR: madatory argument '-S' missing\n"; + usage(); + exit 1; +} + +if (exists($options{s})) { + $startmem = $options{s}; +} + +if (exists($options{n})) { + $num_members = $options{n}; +} + +if (exists($options{m})) { + $member_prefix = $options{m}; +} +else { + print "ERROR: mandatory argument '-m' missing\n"; + usage(); + exit 1; +} + +if (exists($options{G})) { + $startgroup = $options{G}; +} + +if (exists($options{N})) { + $num_groups = $options{N}; +} + +if (exists($options{P})) { + $path = $options{p}; + $net_path = "$path/$net_cmd"; +} + +if (@ARGV) { + print "ERROR: junk on the command line ('" . join(" ", @ARGV) . "')...\n"; + usage(); + exit 1; +} + +# utility functions: + +sub do_add { + my $member_name = shift; + my $group_name = shift; + print "adding member $member_name to group $group_name\n"; + system("$net_path rpc -I $server ".$creds." group addmem $group_name $member_name"); +} + +sub add_group_loop { + my $member_name = shift; + + if ("x$startgroup" eq "x") { + do_add($member_name, $group_prefix); + } + else { + for (my $groupnum = 1; $groupnum <= $num_groups; ++$groupnum) { + do_add($member_name, + sprintf("%s%.05d", $group_prefix, $startgroup + $groupnum - 1)); + } + } +} + + +# main: + +if ("x$startmem" eq "x") { + add_group_loop($member_prefix); +} +else { + for (my $memnum = 1; $memnum <= $num_members; ++$memnum) { + add_group_loop(sprintf("%s%.05d", $member_prefix, $startmem + $memnum - 1)); + } +} + -- cgit From 57d6b313dfb29cb753f66358d972e473b7d251da Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 9 Nov 2007 11:17:18 +0100 Subject: Find and fix more GPL2 -> GPL3. Jeremy. This adapts r23780 / c2f7ab1c175ecff0cf44d0bbc4763ba9f7d7803f for files added by cherry-pick. (This used to be commit 1b6cf93992fbe338dff83a9f904ec9dfc422e242) --- examples/scripts/users_and_groups/adduserstogroups.pl | 2 +- examples/scripts/users_and_groups/createdomobj.pl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'examples/scripts/users_and_groups') diff --git a/examples/scripts/users_and_groups/adduserstogroups.pl b/examples/scripts/users_and_groups/adduserstogroups.pl index 335dad00aa..52a7d01703 100755 --- a/examples/scripts/users_and_groups/adduserstogroups.pl +++ b/examples/scripts/users_and_groups/adduserstogroups.pl @@ -10,7 +10,7 @@ # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free -# Software Foundation; either version 2 of the License, or (at your option) +# Software Foundation; either version 3 of the License, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but WITHOUT diff --git a/examples/scripts/users_and_groups/createdomobj.pl b/examples/scripts/users_and_groups/createdomobj.pl index 6568b21664..36e0c0f9fd 100755 --- a/examples/scripts/users_and_groups/createdomobj.pl +++ b/examples/scripts/users_and_groups/createdomobj.pl @@ -10,7 +10,7 @@ # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free -# Software Foundation; either version 2 of the License, or (at your option) +# Software Foundation; either version 3 of the License, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but WITHOUT -- cgit From 62fcfe988cc442742ca59e4c48c3793c5ed56a8c Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 9 Nov 2007 11:18:45 +0100 Subject: The FSF has moved around a lot. This fixes their Mass Ave address. This adapts r23801 / 87c91e4362c51819032bfbebbb273c52e203b227 to files just added by cherry-pick. Michael (This used to be commit a0d595c2277d2f754cdb0c85119fdc130d86f7ea) --- examples/scripts/users_and_groups/adduserstogroups.pl | 3 +-- examples/scripts/users_and_groups/createdomobj.pl | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'examples/scripts/users_and_groups') diff --git a/examples/scripts/users_and_groups/adduserstogroups.pl b/examples/scripts/users_and_groups/adduserstogroups.pl index 52a7d01703..17ca5bd842 100755 --- a/examples/scripts/users_and_groups/adduserstogroups.pl +++ b/examples/scripts/users_and_groups/adduserstogroups.pl @@ -19,8 +19,7 @@ # more details. # # You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 675 -# Mass Ave, Cambridge, MA 02139, USA. +# this program; if not, see . # # diff --git a/examples/scripts/users_and_groups/createdomobj.pl b/examples/scripts/users_and_groups/createdomobj.pl index 36e0c0f9fd..60f34b84f2 100755 --- a/examples/scripts/users_and_groups/createdomobj.pl +++ b/examples/scripts/users_and_groups/createdomobj.pl @@ -19,8 +19,7 @@ # more details. # # You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 675 -# Mass Ave, Cambridge, MA 02139, USA. +# this program; if not, see . # # -- cgit From c402ec1bd84ca09ba9e0b1bd122bfc34fb089772 Mon Sep 17 00:00:00 2001 From: Karolin Seeger Date: Fri, 9 Nov 2007 11:30:30 +0100 Subject: Fix typo (This used to be commit e811b9f3bbf614f76e628755dafd358769b8a58b) --- examples/scripts/users_and_groups/adduserstogroups.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/scripts/users_and_groups') diff --git a/examples/scripts/users_and_groups/adduserstogroups.pl b/examples/scripts/users_and_groups/adduserstogroups.pl index 17ca5bd842..6759428774 100755 --- a/examples/scripts/users_and_groups/adduserstogroups.pl +++ b/examples/scripts/users_and_groups/adduserstogroups.pl @@ -47,7 +47,7 @@ my $creds; sub usage { print "USAGE: $0 [-h] -S server -U user\%pass \\\n" . "\t-m member [-s startmem] [-n nummem] \\\n" - . "\t-g group [-G stargroup] [-N numgroups] \\\n" + . "\t-g group [-G startgroup] [-N numgroups] \\\n" . "\t[-P path]\n"; } -- cgit