#!/bin/bash
DIR=`dirname $0`

usage(){
    echo "Usage $0 names.txt"
    echo "Reads a list of name corresponding to some ldap users"
    echo "and run $DIR/create_primtux_user.sh on each of them"
}

if [ -z "$1" ]
then
    usage
    exit 1
fi

if [ ! -f "$1" ]
then
    echo "$1 is not a file"
    usage
    exit 1
fi

while read first last level
do
    echo $first
    echo $last
    echo $level
    uid=`ldapsearch -x cn="$first $last" | grep "^uid:" | cut -f ' ' -d 2`
    echo $uid
    echo $DIR/create_primtux_user.sh $uid $level
done < $1
