[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3master/usr/share/se3/sbin/ -> mail-ldap.sh (source)

   1  #!/bin/bash
   2  # SambaEdu
   3  #
   4  # $Id: mail-ldap.sh 7723 2013-03-18 23:57:26Z keyser $
   5  #
   6   
   7  WWWPATH="/var/www"
   8  
   9  if [ -e $WWWPATH/se3/includes/config.inc.php ]; then
  10          dbhost=`cat $WWWPATH/se3/includes/config.inc.php | grep "dbhost=" | cut -d = -f 2 |cut -d \" -f 2`
  11      dbname=`cat $WWWPATH/se3/includes/config.inc.php | grep "dbname=" | cut -d = -f 2 |cut -d \" -f 2`
  12      dbuser=`cat $WWWPATH/se3/includes/config.inc.php | grep "dbuser=" | cut -d = -f 2 |cut -d \" -f 2`
  13      dbpass=`cat $WWWPATH/se3/includes/config.inc.php | grep "dbpass=" | cut -d = -f 2 |cut -d \" -f 2`
  14  else
  15      echo "Fichier de conf inaccessible"
  16          exit 1
  17  fi
  18  BASEDN=`echo "SELECT value FROM params WHERE name='ldap_base_dn'" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N`
  19  if [ -z "$BASEDN" ]; then
  20          echo "Impossible d'accéder au paramètre BASEDN"
  21          exit 1
  22  fi
  23  
  24  RIGHTSRDN=`echo "SELECT value FROM params WHERE name='RightsRdn'" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N`
  25  if [ -z "$RIGHTSRDN" ]; then
  26          echo "Impossible d'accéder au paramètre RIGHTSRDN"
  27          exit 1
  28  fi
  29          
  30  PEOPLERDN=`echo "SELECT value FROM params WHERE name='peopleRdn'" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N`
  31  if [ -z "$PEOPLERDN" ]; then
  32          echo "Impossible d'accéder au paramètre PEOPLERDN"
  33          exit 1
  34  fi
  35  
  36  if [ "$1" == "" ]
  37  then 
  38      echo "vous devez indiquer un droit existant"
  39      echo "Les droits existants sont :"
  40      ldapsearch  -x -b $RIGHTSRDN,$BASEDN '(objectclass=*)'  | grep cn |  grep -v requesting | grep -i -v Rights | grep -i -v member 
  41  else    
  42      ldapsearch  -x -b cn=$1,$RIGHTSRDN,$BASEDN '(objectclass=groupOfNames)' member | grep member | grep -v requesting | while read A
  43      do
  44          echo "$A" | cut -d: -f2 | cut -d, -f1 | while read B
  45              do
  46                   ldapsearch  -x -b $B,$PEOPLERDN,$BASEDN '(objectclass=*)' mail | grep mail | grep -v requesting | cut -d: -f2
  47              done
  48      done
  49  fi


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