[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 #!/bin/bash 2 3 # 4 ## $Id: convertapple.sh 7723 2013-03-18 23:57:26Z keyser $ ## 5 # 6 ##### Convertion de l'annuaire LDAP du format Samba 2 au format samba 3 ##### 7 # 8 9 if [ "$1" = "--help" -o "$1" = "-h" ] 10 then 11 echo "Convertion de l'annuaire pour l'integration de clients OSX" 12 echo "Usage : Pas d'option" 13 exit 14 fi 15 16 # 17 # Récupération des paramètres mysql 18 # 19 if [ -e /var/www/se3/includes/config.inc.php ]; then 20 dbhost=`cat /var/www/se3/includes/config.inc.php | grep "dbhost=" | cut -d = -f 2 |cut -d \" -f 2` 21 dbname=`cat /var/www/se3/includes/config.inc.php | grep "dbname=" | cut -d = -f 2 |cut -d \" -f 2` 22 dbuser=`cat /var/www/se3/includes/config.inc.php | grep "dbuser=" | cut -d = -f 2 |cut -d \" -f 2` 23 dbpass=`cat /var/www/se3/includes/config.inc.php | grep "dbpass=" | cut -d = -f 2 |cut -d \" -f 2` 24 else 25 echo "Fichier de conf inaccessible" >> $SE3LOG 26 echo "sauve.sh: Status FAILED" >> $SE3LOG 27 exit 1 28 fi 29 30 # 31 # Recuperation des params LDAP 32 # 33 34 BASEDN=`echo "SELECT value FROM params WHERE name='ldap_base_dn'" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N` 35 if [ -z "$BASEDN" ]; then 36 echo "Impossible d'accéder au paramètre BASEDN" 37 exit 1 38 fi 39 PEOPLERDN=`echo "SELECT value FROM params WHERE name='peopleRdn'" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N` 40 if [ -z "$PEOPLERDN" ]; then 41 echo "Impossible d'accéder au paramètre PEOPLEDN" 42 exit 1 43 fi 44 ADMINRDN=`echo "SELECT value FROM params WHERE name='adminRdn'" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N` 45 if [ -z "$ADMINRDN" ]; then 46 echo "Impossible d'accéder au paramètre ADMINRDN" 47 exit 1 48 fi 49 ADMINPW=`echo "SELECT value FROM params WHERE name='adminPw'" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N` 50 if [ -z "$ADMINPW" ]; then 51 echo "Impossible d'accéder au paramètre ADMINPW" 52 exit 1 53 fi 54 SE3NAME=`cat /etc/samba/smb.conf | grep "netbios name" |cut -d"=" -f2 | sed -e "s/ //g"` 55 56 # On recupere les anciennes entrees 57 echo "" > /tmp/apple_mod.ldif 58 59 ldapsearch -xLLL -D $ADMINRDN,$BASEDN -w $ADMINPW -b $PEOPLERDN,$BASEDN objectCLass=posixAccount dn | grep dn | while read dn; do 60 SUID=`echo $dn|cut -d"=" -f2 | cut -d"," -f1` 61 echo "$dn" >> /tmp/apple_mod.ldif 62 echo "changetype: modify">> /tmp/apple_mod.ldif 63 echo "add: objectClass">> /tmp/apple_mod.ldif 64 echo "objectClass: apple-user">> /tmp/apple_mod.ldif 65 echo "">> /tmp/apple_mod.ldif 66 echo "$dn" >> /tmp/apple_mod.ldif 67 echo "changetype: modify">> /tmp/apple_mod.ldif 68 echo "add: apple-user-homeDirectory">> /tmp/apple_mod.ldif 69 echo "apple-user-homeDirectory: /Users/Network/se3/$SUID">> /tmp/apple_mod.ldif 70 echo "">> /tmp/apple_mod.ldif 71 echo "$dn" >> /tmp/apple_mod.ldif 72 echo "changetype: modify">> /tmp/apple_mod.ldif 73 echo "add: apple-user-homeurl">> /tmp/apple_mod.ldif 74 echo "apple-user-homeurl: <homedir><url>smb://$SE3NAME/osx</url><path>$SUID</path></homedir>">> /tmp/apple_mod.ldif 75 echo "">> /tmp/apple_mod.ldif 76 done 77 78 79 # On modifie les nouvelles entrees 80 ldapmodify -x -c -D $ADMINRDN,$BASEDN -w $ADMINPW -f /tmp/apple_mod.ldif
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 |