[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3master/usr/share/se3/sbin/ -> gecosCorrect.pl (source)

   1  #!/usr/bin/perl
   2  
   3  use Net::LDAP;
   4  use Encode::compat;
   5  use Encode qw(encode decode);
   6  #use Text::Unaccent;
   7  
   8  require '/etc/SeConfig.ph';
   9  
  10  $ldap = Net::LDAP->new(
  11                  "$slapdIp",
  12                  port    => "$slapdPort",
  13                  debug   => "$slapdDebug",
  14                  timeout => "$slapdTimeout",
  15                  version => "$slapdVersion"
  16                 );
  17  $ldap->bind(
  18           $adminDn,
  19           password => $adminPw
  20          );
  21  
  22  $res = $ldap->search(
  23               base   => "$peopleRdn,$baseDn",
  24               scope  => 'one',
  25               filter => 'uid=*'
  26              );
  27  warn $res->error if $res->code != LDAP_SUCCESS;
  28  
  29  foreach $entry ($res->entries) {
  30    
  31    $dn = $entry->dn;
  32    #$cn    = unac_string('utf8', ($entry->get_value('cn')));
  33    $cn1    = $entry->get_value('cn');
  34    $cn=unac(`echo "$cn1" | iconv -f utf8 -t iso8859-1`);
  35    chomp ($cn);
  36    #$gecos = unac_string('utf8', ($entry->get_value('gecos')));
  37    $gecos1 = $entry->get_value('gecos');
  38    $gecos=unac(`echo "$gecos1" | iconv -f utf8 -t iso8859-1`);
  39    chomp($gecos);
  40    $newGecos = "$cn,$gecos";
  41  
  42    
  43    unless ($gecos =~ /^$cn/) {
  44      $res = $ldap->modify(
  45               $dn,
  46               replace => {
  47                       gecos => "$newGecos",
  48                      }
  49              );
  50    }
  51    warn $res->error if $res->code != LDAP_SUCCESS;
  52  }
  53  
  54  sub unac($uid)
  55  {
  56  my ( $uid ) = @_;
  57  # Nettoyage des caract\xe8res accentu\xe9s de l'uid
  58    $uid =~ tr/\x80-\xbf//;
  59    $uid =~ tr/\xc0-\xc5/AAAAAA/;
  60    $uid =~ tr/\xc6//;
  61    $uid =~ tr/\xc7-\xcf/CEEEEIIII/;
  62    $uid =~ tr/\xd0//;
  63    $uid =~ tr/\xd1-\xd6/NOOOOO/;
  64    $uid =~ tr/\xd7//;
  65    $uid =~ tr/\xd8-\xdc/OUUUU/;
  66    $uid =~ tr/\xdd-\xdf//;
  67    $uid =~ tr/\xe0-\xe5/aaaaaa/;
  68    $uid =~ tr/\xe6//;
  69    $uid =~ tr/\xe7-\xef/ceeeeiiii/;
  70    $uid =~ tr/\xf0//;
  71    $uid =~ tr/\xf1-\xf6/nooooo/;
  72    $uid =~ tr/\xf7//;
  73    $uid =~ tr/\xf8-\xfc/ouuuu/;
  74    $uid =~ tr/\xfd-\xff//;
  75    $uid =~ tr/\x0a//;
  76    $uid =~ tr/\x0d//;
  77    return $uid;
  78  }


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1