diff options
author | Gerald Carter <jerry@samba.org> | 2003-09-24 15:08:05 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2003-09-24 15:08:05 +0000 |
commit | 4b10dd945476a93fd9a7d3e047cff7592935ad34 (patch) | |
tree | 7e323e0e3bfe6bd8da4e3d84bdb2340963f39c3e /examples | |
parent | 293421f3c64a2adff7dc15f7ad3adb6120c9fd16 (diff) | |
download | samba-4b10dd945476a93fd9a7d3e047cff7592935ad34.tar.gz samba-4b10dd945476a93fd9a7d3e047cff7592935ad34.tar.bz2 samba-4b10dd945476a93fd9a7d3e047cff7592935ad34.zip |
more syncs from 3.0
(This used to be commit bb7d5ce3762afcb14905fc2c1112df8a7475ffe3)
Diffstat (limited to 'examples')
-rw-r--r-- | examples/LDAP/smbldap-tools/AUTHORS | 0 | ||||
-rw-r--r-- | examples/LDAP/smbldap-tools/NEWS | 0 | ||||
-rwxr-xr-x | examples/LDAP/smbldap-tools/smbldap-groupmod.pl | 112 |
3 files changed, 56 insertions, 56 deletions
diff --git a/examples/LDAP/smbldap-tools/AUTHORS b/examples/LDAP/smbldap-tools/AUTHORS deleted file mode 100644 index e69de29bb2..0000000000 --- a/examples/LDAP/smbldap-tools/AUTHORS +++ /dev/null diff --git a/examples/LDAP/smbldap-tools/NEWS b/examples/LDAP/smbldap-tools/NEWS deleted file mode 100644 index e69de29bb2..0000000000 --- a/examples/LDAP/smbldap-tools/NEWS +++ /dev/null diff --git a/examples/LDAP/smbldap-tools/smbldap-groupmod.pl b/examples/LDAP/smbldap-tools/smbldap-groupmod.pl index 4a891a2772..f897101602 100755 --- a/examples/LDAP/smbldap-tools/smbldap-groupmod.pl +++ b/examples/LDAP/smbldap-tools/smbldap-groupmod.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/perl -w # This code was developped by IDEALX (http://IDEALX.org/) and # contributors (their names can be found in the CONTRIBUTORS file). # @@ -23,6 +23,9 @@ use strict; +use FindBin; +use FindBin qw($RealBin); +use lib "$RealBin/"; use smbldap_tools; use smbldap_conf; @@ -70,45 +73,30 @@ if (defined($tmp = $Options{'g'}) and $tmp =~ /\d+/) { } } if (!($gid == $tmp)) { - my $tmpldif = -"dn: cn=$groupName,$groupsdn -changetype: modify -replace: gidNumber -gidNumber: $tmp - -"; - die "$0: error while modifying group $groupName\n" - unless (do_ldapmodify($tmpldif) == 0); - undef $tmpldif; - + my $ldap_master=connect_ldap_master(); + my $modify = $ldap_master->modify ( "cn=$groupName,$groupsdn", + changes => [ + replace => [gidNumber => $tmp] + ] + ); + $modify->code && die "failed to modify entry: ", $modify->error ; + # take down session + $ldap_master->unbind } } -if (defined($newname)) { - my $FILE="|$ldapmodrdn >/dev/null"; - open (FILE, $FILE) || die "$!\n"; - print FILE <<EOF; -cn=$groupName,$groupsdn -cn=$newname - -EOF - ; - close FILE; - die "$0: error while modifying group $groupName\n" if ($?); - - my $tmpldif = -"dn: cn=$newname,$groupsdn -changetype: modify -delete: cn -- -add: cn -cn: $newname - -"; - die "$0: error while modifying group $groupName\n" - unless (do_ldapmodify($tmpldif) == 0); - undef $tmpldif; +if (defined($newname)) { + my $ldap_master=connect_ldap_master(); + my $modify = $ldap_master->moddn ( + "cn=$groupName,$groupsdn", + newrdn => "cn=$newname", + deleteoldrdn => "1", + newsuperior => "$groupsdn" + ); + $modify->code && die "failed to modify entry: ", $modify->error ; + # take down session + $ldap_master->unbind } # Add members @@ -117,16 +105,24 @@ if (defined($Options{'m'})) { my @members = split( /,/, $members ); my $member; foreach $member ( @members ) { - my $tmpldif = -"dn: cn=$groupName,$groupsdn -changetype: modify -add: memberUid -memberUid: $member - -"; - die "$0: error while modifying group $groupName\n" - unless (do_ldapmodify($tmpldif) == 0); - undef $tmpldif; + if (is_unix_user($member)) { + if (is_group_member("cn=$groupName,$groupsdn",$member)) { + print "User $member already in the group\n"; + } else { + print "adding user $member to group $groupName\n"; + my $ldap_master=connect_ldap_master(); + my $modify = $ldap_master->modify ( "cn=$groupName,$groupsdn", + changes => [ + add => [memberUid => $member] + ] + ); + $modify->code && warn "failed to add entry: ", $modify->error ; + # take down session + $ldap_master->unbind + } + } else { + print "User $member does not exist: create it first !\n"; + } } } @@ -136,16 +132,20 @@ if (defined($Options{'x'})) { my @members = split( /,/, $members ); my $member; foreach $member ( @members ) { - my $tmpldif = -"dn: cn=$groupName,$groupsdn -changetype: modify -delete: memberUid -memberUid: $member - -"; - die "$0: error while modifying group $groupName\n" - unless (do_ldapmodify($tmpldif) == 0); - undef $tmpldif; + if (is_group_member("cn=$groupName,$groupsdn",$member)) { + print "deleting user $member from group $groupName\n"; + my $ldap_master=connect_ldap_master(); + my $modify = $ldap_master->modify ( "cn=$groupName,$groupsdn", + changes => [ + delete => [memberUid => $member] + ] + ); + $modify->code && warn "failed to delete entry: ", $modify->error ; + # take down session + $ldap_master->unbind + } else { + print "User $member is not in the group $groupName!\n"; + } } } |