[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 #!/usr/bin/perl 2 ## script d'attribution des groupes LDAP de l'absent au remplacant 3 ## pschwarz Mai 2005 4 # Lancé par remplacant.php 5 # Usage : perl remplace.pl uid_de_l_absent uid_du_remplacant 6 7 use Net::LDAP; 8 require '/etc/SeConfig.ph'; 9 10 my $absent = $ARGV[0]; 11 my $remplacant = $ARGV[1]; 12 my $urlabsent= "<a href=\"../annu/people.php?uid=$absent\"> $absent </a>"; 13 my $urlremplacant= "<a href=\"../annu/people.php?uid=$remplacant\"> $remplacant </a>"; 14 15 $stop=1; 16 17 $ldap = Net::LDAP->new( 18 "$slapdIp", 19 port => "$slapdPort", 20 debug => "$slapdDebug", 21 timeout => "$slapdTimeout", 22 version => "$slapdVersion" 23 ); 24 $ldap->bind(); # Anonymous BIND 25 26 $ldap->bind( 27 $adminDn, 28 password => $adminPw 29 ); 30 31 $ABS = $ldap->search( 32 base => "ou=People,$baseDn", 33 scope => 'one', 34 filter => "uid=$absent" 35 ); 36 37 if (!($ABS->entries)[0]) {print "<BR>Le professeur $urlabsent n'existe pas.<BR>"; $stop=0;} 38 39 if ( $stop) 40 {$RPL = $ldap->search( 41 base => "ou=People,$baseDn", 42 scope => 'one', 43 filter => "uid=$remplacant" 44 ); 45 if (!($RPL->entries)[0]) {print "<BR>Le professeur $urlremplacant n'existe pas.<BR>";$stop=0;} 46 } 47 48 #foreach $parcoursABS ($ABS->entries) {$nomabsent = $parcoursABS->dn;} 49 #foreach $parcoursRPL ($RPL->entries) {$nomremplacant = $parcoursRPL->dn;} 50 if ( $stop) 51 {if ($absent=~m/$remplacant/) {print "<BR>Le professeur $urlremplacant se remplace lui-même; Vous appliquez les décisions du ministre. C'est bien, poursuivez.<BR>"; $stop=0;}} 52 53 if ( $stop) 54 {$grpesABS = $ldap->search( 55 base => "ou=Groups,$baseDn", 56 scope => 'one', 57 filter => "memberuid=$absent" 58 ); 59 $nbre=$grpesABS->count(); 60 if ($nbre < 2) {print "<BR>Le professeur <B>$urlabsent</B> n'appartient à aucun groupe secondaire.<BR>";$stop=0;}} 61 62 if ( $stop) 63 {$grpesRPL = $ldap->search( 64 base => "ou=Groups,$baseDn", 65 scope => 'one', 66 filter => "memberuid=$remplacant" 67 ); 68 #On créee un hachage contenant tous les groupes de l'absent??ou du remplacant??? 69 %RPL=(); 70 foreach $people ($grpesRPL->entries) { 71 $dnRPL = $people->dn; 72 $dnRPLAFF=$dnRPL; 73 $dnRPLAFF=~s/,ou=Groups,$baseDn//; 74 $dnRPLAFF=~s/cn=//; 75 76 $RPL{"$dnRPLAFF"}= $dnRPL; 77 } 78 } 79 80 81 82 if ( $stop) 83 { 84 $cpt=0; 85 foreach $people ($grpesABS->entries) { 86 $dnABS = $people->dn; 87 $dnABSAFF=$dnABS; 88 $dnABSAFF=~s/,ou=Groups,$baseDn//; 89 $dnABSAFF=~s/cn=//; 90 91 # foreach my $grpesABS (values(%RPL)){ 92 #if (! ( ($dnABS=~m/$grpesABS/) ) ) 93 #{$CHECKED="";} 94 #else 95 #{$CHECKED="CHECKED";} 96 #} 97 if ( exists ( $RPL {$dnABSAFF} ) ) 98 {print "<BR> $dnABSAFF"; } 99 else 100 {$cpt++; 101 print "<BR><INPUT NAME=\"GRPE$cpt\" TYPE=\"CHECKBOX\" VALUE=\"$dnABS\" CHECKED>$dnABSAFF"; 102 } 103 } 104 } 105 $ldap->unbind(); 106
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 |