syncing examples
[Samba.git] / examples / LDAP / smbldap-tools / smbldap-groupdel.pl
blob3d072585b21b60d6200b3d085c43bcec3dfd6d86
1 #!/usr/bin/perl
3 # This code was developped by IDEALX (http://IDEALX.org/) and
4 # contributors (their names can be found in the CONTRIBUTORS file).
6 # Copyright (C) 2001-2002 IDEALX
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License
10 # as published by the Free Software Foundation; either version 2
11 # of the License, or (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 # USA.
23 # Purpose of smbldap-groupdel : group (posix) deletion
25 use strict;
26 use smbldap_tools;
27 use smbldap_conf;
29 #####################
31 use Getopt::Std;
32 my %Options;
34 my $ok = getopts('?', \%Options);
35 if ( (!$ok) || (@ARGV < 1) || ($Options{'?'}) ) {
36 print "Usage: $0 groupname\n";
37 print " -? show this help message\n";
38 exit (1);
41 my $_groupName = $ARGV[0];
43 my $dn_line;
44 if (!defined($dn_line = get_group_dn($_groupName))) {
45 print "$0: group $_groupName doesn't exist\n";
46 exit (6);
49 my $dn = get_dn_from_line($dn_line);
51 my $rc = system "$ldapdelete $dn >/dev/null";
52 die "$0: error while deleting group $_groupName\n"
53 unless ($rc == 0);
55 my $nscd_status = system "/etc/init.d/nscd status >/dev/null 2>&1";
57 if ($nscd_status == 0) {
58 system "/etc/init.d/nscd restart > /dev/null 2>&1";
61 #if (defined($dn_line = get_group_dn($_groupName))) {
62 # print "$0: failed to delete group\n";
63 # exit (7);
67 exit (0);
69 ############################################################
71 =head1 NAME
73 smbldap-groupdel.pl - Delete a group
75 =head1 SYNOPSIS
77 smbldap-groupdel.pl group
79 =head1 DESCRIPTION
81 The smbldap-groupdel.pl command modifies the system account files,
82 deleting all entries that refer to group. The named group must exist.
84 You must manually check all filesystems to insure that no files remain
85 with the named group as the file group ID.
87 =head1 SEE ALSO
89 groupdel(1)
91 =cut