~ubuntu-branches/ubuntu/lucid/samba/lucid-proposed

« back to all changes in this revision

Viewing changes to examples/LDAP/smbldap-tools-0.8.7/smbldap-groupdel

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-07-21 17:53:23 UTC
  • mfrom: (0.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050721175323-m3oh6aoigywohfnq
Tags: 3.0.14a-6ubuntu1
Resynchronise with Debian, resolving merge conflicts (#12360)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
 
 
3
# $Id: smbldap-groupdel,v 1.7 2004/11/06 17:54:26 jtournier Exp $
 
4
#
 
5
#  This code was developped by IDEALX (http://IDEALX.org/) and
 
6
#  contributors (their names can be found in the CONTRIBUTORS file).
 
7
#
 
8
#                 Copyright (C) 2001-2002 IDEALX
 
9
#
 
10
#  This program is free software; you can redistribute it and/or
 
11
#  modify it under the terms of the GNU General Public License
 
12
#  as published by the Free Software Foundation; either version 2
 
13
#  of the License, or (at your option) any later version.
 
14
#
 
15
#  This program is distributed in the hope that it will be useful,
 
16
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
#  GNU General Public License for more details.
 
19
#
 
20
#  You should have received a copy of the GNU General Public License
 
21
#  along with this program; if not, write to the Free Software
 
22
#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 
23
#  USA.
 
24
 
 
25
# Purpose of smbldap-groupdel : group (posix) deletion
 
26
 
 
27
use strict;
 
28
use FindBin;
 
29
use FindBin qw($RealBin);
 
30
use lib "$RealBin/";
 
31
use smbldap_tools;
 
32
 
 
33
#####################
 
34
use Getopt::Std;
 
35
my %Options;
 
36
 
 
37
my $ok = getopts('?', \%Options);
 
38
if ( (!$ok) || (@ARGV < 1) || ($Options{'?'}) ) {
 
39
  print_banner;
 
40
  print "Usage: $0 groupname\n";
 
41
  print "  -?   show this help message\n";
 
42
  exit (1);
 
43
}
 
44
 
 
45
my $_groupName = $ARGV[0];
 
46
 
 
47
my $ldap_master=connect_ldap_master();
 
48
 
 
49
my $dn_line;
 
50
if (!defined($dn_line = get_group_dn($_groupName))) {
 
51
  print "$0: group $_groupName doesn't exist\n";
 
52
  exit (6);
 
53
}
 
54
 
 
55
my $dn = get_dn_from_line($dn_line);
 
56
 
 
57
group_del($dn);
 
58
 
 
59
my $nscd_status = system "/etc/init.d/nscd status >/dev/null 2>&1";
 
60
 
 
61
if ($nscd_status == 0) {
 
62
  system "/etc/init.d/nscd restart > /dev/null 2>&1";
 
63
}
 
64
 
 
65
#if (defined($dn_line = get_group_dn($_groupName))) {
 
66
#    print "$0: failed to delete group\n";
 
67
#    exit (7);
 
68
#}
 
69
 
 
70
# take down session
 
71
$ldap_master->unbind;
 
72
 
 
73
 
 
74
exit (0);
 
75
 
 
76
############################################################
 
77
 
 
78
=head1 NAME
 
79
 
 
80
       smbldap-groupdel - Delete a group
 
81
 
 
82
=head1 SYNOPSIS
 
83
 
 
84
       smbldap-groupdel group
 
85
 
 
86
=head1 DESCRIPTION
 
87
 
 
88
       The smbldap-groupdel command modifies the system account files,
 
89
       deleting all entries that refer to a group.
 
90
       The named group must exist.
 
91
 
 
92
       You must manually check all filesystems to insure that no files remain
 
93
       with the named group as the file group ID.
 
94
 
 
95
=head1 SEE ALSO
 
96
 
 
97
       groupdel(1)
 
98
 
 
99
=cut
 
100
 
 
101
#'