@@ -35,31 +35,21 @@ while getopts "u:p:dhUof" o; do
3535done
3636if [[ " $f " == " 1" ]]; then
3737 debug_msg " Forcing login attempt"
38- force_login
3938fi
4039
4140
42- debug_msg " Username: $username "
4341debug_msg " LoginURL: $login_url "
4442
4543
4644# Check if already logged in
47- debug_msg " Checking if already connected"
48- if wget -qT 5 -t 1 --spider --no-check-certificate https://google.com
49- then
50- send_msg " Already logged into the BITSnet"
51- exit
52- fi
53-
54-
55- # Check if username or password are empty
56- debug_msg " Checking if username or password is empty"
57- if [[ (" $username " == " " ) || (" $password " == " " ) ]]; then
58- send_msg " Username or password empty"
59- debug_msg " Exiting"
60- exit
45+ if [[ " $f " != " 1" ]]; then
46+ debug_msg " Checking if already connected"
47+ if wget -qT 5 -t 1 --spider --no-check-certificate https://google.com
48+ then
49+ send_msg " Already logged into the BITSnet"
50+ exit
51+ fi
6152fi
62- debug_msg " Not empty"
6353
6454
6555# Check if using wifi or ethernet
@@ -69,7 +59,7 @@ dev=$(get_device)
6959debug_msg " dev = $dev "
7060
7161# Exit if dev = 0
72- if [[ " $dev " == " 0" ]]; then
62+ if [[ " $f " == " 0 " && " $ dev" == " 0" ]]; then
7363 debug_msg " Exiting because dev is zero"
7464 send_msg " Network interface unknown."
7565 exit
@@ -85,14 +75,26 @@ if [[ "$dev" == "2" && "$(hostname -I)" != "10.20"* ]]; then
8575 debug_msg " Connected to wifi. Sending request to cisco router form"
8676 router_login
8777fi
78+
8879# Log into the ldap
8980debug_msg " Logging into the LDAP"
90- reply=$( ldap_login)
81+ i=1
82+ while [[ ! -z ${username[$i]} ]]
83+ do
84+ debug_msg " Trying with ID: ${username[$i]} "
85+ reply=$( ldap_login ${username[$i]} ${password[$i]} )
86+
87+ # Extract reply
88+ reply=$( extract_msg $reply )
89+
90+ if [[ " $reply " == " You have successfully logged in" ]]; then
91+ break
92+ else
93+ debug_msg " $reply "
94+ fi
95+ (( i++ ))
9196
92-
93- # Extract reply
94- debug_msg " Extracting reply"
95- reply=$( extract_msg $reply )
97+ done
9698
9799
98100# Display reply or send a notification
0 commit comments