start=$1
for user in $(ldapsearch -x "(&(!(objectclass=responsable))(!(uid=*$))(uid=$start*))" | grep uid: | cut -d' ' -f2);do
firstletter="${user:0:1}"
home="/home/$firstletter/$user"
adhome="/home/adhomes/$user"
if [ -d "$home" ];then
    if [ ! -L "$home" ];then
        if [ -d "$adhome" ];then
            contenu="$(ls $adhome)"
            if [ "$contenu" != "groupes" ];then
                echo "attention : $contenu"
                break
            fi
            rm -rf $adhome
        else
            echo "Correction de $user"
            break
            #mv $home $adhome
            #ln -nsf $adhome $home
        fi
    else
        echo "$user : OK"
    fi
else
     echo "Correction : $home"
     break
     #ln -nsf $adhome $home     
fi
# pour le profil !
chown $user $adhome
done

