PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : samba&ldap + accounts sollen sich nur einmal anmelden können?



Bloggy
28.02.08, 12:29
Hi,

Hier läuft ein DC mit samba&ldap, ist es irgentwie möglich samba
beizubringen das sich jeder account nur einmal anmelden kann, also
nicht gleichzeitig an zwei Clients?

mamue
28.02.08, 15:47
Du kannst festlegen, an welchen Workstations sich ein user anmelden darf. Alternativ könnte man versuchen über den root preexec Mechanismus ein zweites Anmelden zu verhindern (vorrübergehendes deaktivieren des Accounts; setzen der workstation).
Andere Möglichkeiten sind mir nicht bekannt.

HTH,
mamue

Bloggy
18.03.08, 13:53
Hallo, ich habe mir ein Script geschrieben was die Kontrolle der Logins ermöglicht und diese auf einen pro Benutzer beschränkt, indem es sobald sich ein Benutzer einlogt diesem im LDAP das Attribut "sambaUserWorkastation" erstellt und die Workstation einträgt...



USERONMACHINEPATH="/var/cache/server.control/online";
LOGPATH="/var/log/atlantis";
CONNECTIONLOG="smb_connection.log";
TMPPATH="/tmp";

function bind_user_to_machine_exist(){
pid="$1";
username="$2";
machine="$3";
ls -l "$USERONMACHINEPATH/"|grep "$pid"&&echo "EXIST"||echo "NOT_EXIST";
}
function monitoring(){
echo "Starte Monitoring und Automatisierungen...";
rm -f $USERONMACHINEPATH/*;
test_tmpfile_A=`test -e $TMPPATH/tmp.server.control.userONmachine.tb&&echo "1"||echo "0"`;
test_tmpfile_B=`test -e $TMPPATH/tmp2.server.control.userONmachine.tb&&echo "1"||echo "0"`;
test_tmpfile_C=`test -e $TMPPATH/tmp3.server.control.userONmachine.tb&&echo "1"||echo "0"`;
test_tmpfile_D=`test -e $TMPPATH/tmp.ldap.server.control.userONmachine.tb&&echo "1"||echo "0"`;
if [ "$test_tmpfile_A" == "1" ];then
rm -f tmp.server.control.userONmachine.tb
fi
if [ "$test_tmpfile_B" == "1" ];then
rm -f tmp2.server.control.userONmachine.tb
fi
if [ "$test_tmpfile_C" == "1" ];then
rm -f tmp3.server.control.userONmachine.tb
fi
if [ "$test_tmpfile_D" == "1" ];then
rm -f tmp.ldap.server.control.userONmachine.tb
fi
while /bin/true;
do
smbstatus -b|cat -n > $TMPPATH/tmp.server.control.userONmachine.tb
cat $TMPPATH/tmp.server.control.userONmachine.tb|while read lineA
do
linenumberA=`echo $lineA|awk 'BEGIN {FS = " "} {print $1}'`;
testlinenumberA=`echo "$linenumberA > 4"|bc -qi`;
if [ "$testlinenumberA" == "1" ];then
pidA=`echo $lineA|awk 'BEGIN {FS = " "} {print $2}'`;
usernameA=`echo $lineA|awk 'BEGIN {FS = " "} {print $3}'`;
machineA=`echo $lineA|awk 'BEGIN {FS = " "} {print $5}'`;
if [ "$machineA" == "Admins" ];then
machineA=`echo $lineA|awk 'BEGIN {FS = " "} {print $6}'`;
elif [ "$machineA" == "Guest" ];then
machineA=`echo $lineA|awk 'BEGIN {FS = " "} {print $6}'`;
elif [ "$machineA" == "Users" ];then
machineA=`echo $lineC|awk 'BEGIN {FS = " "} {print $6}'`;
fi
bind_exist=`bind_user_to_machine_exist "$pidA" "$usernameA" "$machineA"`;
if [ "$bind_exist" == "NOT_EXIST" ];then
echo "$machineA $usernameA" > "$USERONMACHINEPATH/$pidA";
DATE=`date + %Y-%m-%d-%H-%M`;
echo "$DATE [login] "$usernameA" "$machineA";
# Set LDAP-Attribut:
echo "dn: cn=$usernameA,ou=people,dc=gesamtschule,dc=troisdo rf,dc=schulnetz" > "$TMPPATH/tmp.ldap.server.control.userONmachine.tb";
echo "chanchetype: modify" >> "$TMPPATH/tmp.ldap.server.control.userONmachine.tb";
echo "replace: sambaUserWorkstation" >> "$TMPPATH/tmp.ldap.server.control.userONmachine.tb";
echo "sambaUserWorkstation: $machineA" >> "$TMPPATH/tmp.ldap.server.control.userONmachine.tb";
#nofunc ldapmodify -f "$TMPPATH/tmp.ldap.server.control.userONmachine.tb";
fi
fi
done
ls -l "$USERONMACHINEPATH"|awk 'BEGIN {FS = " "} {print $9}'|cat -n > $TMPPATH/tmp2.server.control.userONmachine.tb
cat $TMPPATH/tmp2.server.control.userONmachine.tb|while read lineB
do
echo "0" > "$TMPPATH/tmp3.server.control.userONmachine.tb";
linenumberB=`echo $lineB |awk 'BEGIN {FS = " "} {print $1}'`;
testlinenumberB=`echo "$linenumberB > 1"|bc -qi`;
if [ "$testlinenumberB" == "1" ];then
pidB=`echo $lineB |awk 'BEGIN {FS = " "} {print $2}'`;
machineB=`cat "$USERONMACHINEPATH/$pidB"|awk 'BEGIN {FS = " "} {print $1}'`;
usernameB=`cat "$USERONMACHINEPATH/$pidB"|awk 'BEGIN {FS = " "} {print $2}'`;
cat -n $TMPPATH/tmp.server.control.userONmachine.tb|while read lineC
do
linenumberC=`echo $lineC|awk 'BEGIN {FS = " "} {print $1}'`;
testlinenumberC=`echo "$linenumberC > 4"|bc -qi`;
if [ "$testlinenumberC" == "1" ];then
pidC=`echo $lineC|awk 'BEGIN {FS = " "} {print $3}'`;
usernameC=`echo $lineC|awk 'BEGIN {FS = " "} {print $4}'`;
machineC=`echo $lineC|awk 'BEGIN {FS = " "} {print $6}'`;
if [ "$machineC" == "Admins" ];then
machineC=`echo $lineC|awk 'BEGIN {FS = " "} {print $7}'`;
elif [ "$machineC" == "Guest" ];then
machineC=`echo $lineC|awk 'BEGIN {FS = " "} {print $7}'`;
elif [ "$machineC" == "Users" ];then
machineC=`echo $lineC|awk 'BEGIN {FS = " "} {print $7}'`;
fi
if [ "$pidB" == "$pidC" ];then
if [ "$machineB" == "$machineC" ];then
echo "1" > "$TMPPATH/tmp3.server.control.userONmachine.tb";
fi
fi
fi
done
isbind=`cat "$TMPPATH/tmp3.server.control.userONmachine.tb"`;
if [ "$isbind" == "0" ];then
if [ "$pidB" != "" ];then
rm -f $USERONMACHINEPATH/$pidB;
DATE=`date + %Y-%m-%d-%H-%M`;
echo "$DATE [logout] "$usernameA" "$machineA";
# Set LDAP-Attribut:
echo "dn: cn=$usernameB,ou=people,dc=gesamtschule,dc=troisdo rf,dc=schulnetz" > "$TMPPATH/tmp.ldap.server.control.userONmachine.tb";
echo "chanchetype: modify" >> "$TMPPATH/tmp.ldap.server.control.userONmachine.tb";
echo "replace: sambaUserWorkstation" >> "$TMPPATH/tmp.ldap.server.control.userONmachine.tb";
echo "sambaUserWorkstation:" >> "$TMPPATH/tmp.ldap.server.control.userONmachine.tb";
#nofunc ldapmodify -f "$TMPPATH/tmp.ldap.server.control.userONmachine.tb";
fi
fi
fi
done
sleep 2;
done
}
case $1 in
-monitoring)
monitoring >>/dev/null&
;;
esac


Falls jemand einen einfachen weg findet bitte bescheid sagen :ugly:
PS: ABER ES LÄUFT :)