[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 #!/usr/bin/perl 2 3 use Net::LDAP; 4 5 require '/etc/SeConfig.ph'; 6 7 die("Erreur d'argument.\n") if ($#ARGV != 0); 8 9 $dn = shift @ARGV; 10 $rdnValue = (split /=/, (split /,/, $dn)[0])[1]; 11 12 $ldap = Net::LDAP->new( 13 "$slapdIp", 14 port => "$slapdPort", 15 debug => "$slapdDebug", 16 timeout => "$slapdTimeout", 17 version => "$slapdVersion" 18 ); 19 $ldap->bind( 20 $adminDn, 21 password => $adminPw 22 ); 23 24 $res = $ldap->delete($dn); 25 26 die("Erreur LDAP : " . $res->error) if ($res->code ne 0); 27 28 $ldap = Net::LDAP->new( 29 "$slapdIp", 30 port => "$slapdPort", 31 debug => "$slapdDebug", 32 timeout => "$slapdTimeout", 33 version => "$slapdVersion" 34 ); 35 $ldap->bind(); # Anonymous BIND 36 $res = $ldap->search( 37 base => "$baseDn", 38 scope => 'sub', 39 attrs => ['dn'], 40 filter => "(&(memberUid=$rdnValue)(objectClass=posixGroup))" 41 ); 42 43 # DEBUG INFO 44 ############# 45 # print "\nFiltre : (&(memberUid=$rdnValue)(objectClass=posixGroup))\n"; 46 47 die("Erreur LDAP : " . $res->error) if ($res->code ne 0); 48 49 foreach $entry ($res->entries) { 50 $dnWhereToDel = $entry->dn; 51 # DEBUG INFO 52 ############# 53 # print "dn : $dnWhereToDel\n"; 54 # FIN DEBUG 55 ############ 56 # print "/usr/share/se3/sbin/groupDelEntry.pl $dn $dnWhereToDel\n"; 57 58 system("/usr/share/se3/sbin/groupDelEntry.pl \"$dn\" \"$dnWhereToDel\""); 59 } 60 61 $res2 = $ldap->search( 62 base => "$baseDn", 63 scope => 'sub', 64 attrs => ['dn'], 65 filter => "(&(member=$dn)(objectClass=groupOfNames))" 66 ); 67 68 # DEBUG INFO 69 ############# 70 # print "\n\nFiltre : (&(member=$dn)(objectClass=groupOfNames))\n"; 71 72 die("Erreur LDAP : " . $res2->error) if ($res2->code ne 0); 73 74 foreach $entry2 ($res2->entries) { 75 $dnWhereToDel2 = $entry2->dn; 76 # DEBUG INFO 77 ############# 78 # print "dn : $dnWhereToDel2\n"; 79 # foreach my $attr2 ($entry2->attributes) { 80 # foreach my $value2 ($entry2->get_value($attr2)) { 81 # print "$attr2 : $value2\n"; 82 # } 83 # } 84 # print "/usr/share/se3/sbin/groupDelEntry.pl $dn $dnWhereToDel2\n"; 85 86 system("/usr/share/se3/sbin/groupDelEntry.pl $dn $dnWhereToDel2"); 87 } 88 89 $res3 = $ldap->search( 90 base => "$baseDn", 91 scope => 'sub', 92 attrs => ['dn'], 93 filter => "owner=$dn" 94 ); 95 96 # DEBUG INFO 97 ############# 98 # print "\n\nFiltre : owner=$dn\n"; 99 100 die("Erreur LDAP : " . $res3->error) if ($res3->code ne 0); 101 102 $ldap->bind( 103 $adminDn, 104 password => $adminPw 105 ); 106 107 foreach $entry3 ($res3->entries) { 108 $dnWhereToDel3 = $entry3->dn; 109 # DEBUG INFO 110 ############# 111 # print "dn : $dnWhereToDel3\n"; 112 # foreach my $attr3 ($entry3->attributes) { 113 # foreach my $value3 ($entry3->get_value($attr3)) { 114 # print "$attr3 : $value3\n"; 115 # } 116 # } 117 # print "/usr/share/se3/sbin/groupDelEntry.pl $dn $dnWhereToDel3\n"; 118 119 120 $res = $ldap->modify( 121 $dnWhereToDel3, 122 delete => { owner => $dn } 123 ); 124 125 die("Erreur LDAP : " . $res->error . ".\n") if ($res->code ne 0); 126 127 } 128 129 $ldap->unbind(); 130 131 exit 0;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |