public function authenticate() { /*if (Request::ajax()):*/ $isAccountActive = FALSE; $adldap = new adLDAP(); $username = Request::input('username'); $password = md5(Request::input('password')); $authUser = $adldap->authenticate($username, Request::input('password')); if ($authUser && $this->login_status) { $user_fields = array('displayname', 'mail', 'company', 'physicaldeliveryofficename', 'givenname', 'sn'); $this->user_info = $adldap->user()->info($username, $user_fields); //working $this->_processUser($username, $password); //return array("status" => $this->response_status, "message" => $this->response_text); } else { $this->login_status = FALSE; $this->_check_failed_login_duration($username); //return array("status" => $this->response_status, "message" => $this->response_text); } //todo WFH. SEARCH FOR VLANS if (!$this->wfh) { // if user is allowed to work from home then check his IP $user_ip_address = Request::getClientIp(true); $tmpIP = $user_ip_address; $pos = strrpos($tmpIP, '.'); $tmpIP = substr($tmpIP, 0, $pos) . '.'; $qry2 = "\n\t\t\t\tSELECT * FROM vlans v \n\t\t\t\tINNER JOIN offices o ON v.office_id = o.office_id \n\t\t\t\tWHERE subnet like '" . $tmpIP . "%';\n\t\t\t"; $res2 = DB::select($qry2); if (count($res2) == 0 && ip2long($user_ip_address)) { $this->login_status = FALSE; $this->response_text = 'You are not authorised to login remotely. If this is incorrect please contact HR.'; $this->response_status = 'failed'; Auth::logout(); return array("status" => $this->response_status, "message" => $this->response_text); } } if (!$this->login_status) { $this->response_status = 'failed'; $this->response_text = $this->messages['invalid']; } return array("status" => $this->response_status, "message" => $this->response_text); /*else: return array("status" => $this->response_status, "message" => $this->response_text); endif;*/ }
/** * Validate a user's login credentials * * @param string $username A user's AD username * @param string $password A user's AD password * @param bool optional $prevent_rebind * @return bool */ public function authenticate($username, $password, $preventRebind = false) { return $this->adldap->authenticate($username, $password, $preventRebind); }