Esempio n. 1
0
 /**
  * Authenticates a user.
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     // CODE FOR LDAP
     // try {
     //     $ldap_check = new LDAPQuery($this->username, $this->password);
     //     if ($ldap_check->get_connection()) {
     //         if(!$ldap_check->get_bind()) $this->errorCode = self::ERROR_PASSWORD_INVALID;
     //         else $this->errorCode = self::ERROR_NONE;
     //     }
     // } catch (LDAPQueryException $e) {
     //     $this->errorCode = self::ERROR_LDAP_BINDING;
     // }
     if (LdapUsers::model()->exists('username=:username', array(':username' => $this->username)) && strlen($this->password) > 0) {
         $this->errorCode = self::ERROR_NONE;
     } else {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     }
     // CODE FOR ADLDAP
     // try {
     //     if (Yii::app()->ldap->authenticate($this->username, $this->password)) {
     //         $this->errorCode = self::ERROR_NONE;
     //     } else {
     //         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     //     }
     // } catch (adLDAPException $e) {
     //     $this->errorCode = self::ERROR_LDAP_BINDING;
     // }
     // send login details
     $sender = new GraphiteSender('statsd');
     $sender->send_login($this->errorCode);
     $sender = new GraphiteSender('direct');
     $sender->send_login($this->errorCode);
     return !$this->errorCode;
 }
Esempio n. 2
0
 private function get_data($filter = '', $limit = 5, $offset = 0)
 {
     $criteria = new CDbCriteria();
     $criteria->join = "JOIN (application_point_persons o JOIN applications a on o.application_id=a.application_id) ON o.username=t.username";
     if (is_array($filter)) {
         if (isset($filter['application_id'])) {
             $criteria->compare('o.application_id', $filter['application_id']);
         }
         if (isset($filter['name'])) {
             $criteria->compare('LOWER(a.name)', strtolower($filter['name']), true, 'AND', true);
         }
         if (isset($filter['point_person'])) {
             $criteria->compare('LOWER(t.name)', strtolower($filter['point_person']), true, 'AND', true);
         }
     }
     $count = LdapUsers::model()->count($criteria);
     $criteria->limit = $limit;
     $criteria->offset = $offset;
     $criteria->order = 'LOWER(t.name)';
     $model = LdapUsers::model()->findAll($criteria);
     $curr_user = '';
     $index = 0;
     $application = null;
     $data = array();
     foreach ($model as $row) {
         // if new
         if ($row->name != $curr_user) {
             $curr_user = $row->name;
             $index = 0;
         }
         $application = $row->applications[$index];
         $data[] = array('application_id' => $application->application_id, 'project_id' => $application->project_id, 'type_id' => $application->type_id, 'name' => str_replace('<', '&lt', $application->name), 'description' => str_replace('<', '&lt', $application->description), 'accessibility' => $application->accessibility, 'repository_url' => str_replace('<', '&lt', $application->repository_url), 'uses_mobile_patterns' => $application->uses_mobile_patterns, 'instructions' => str_replace('<', '&lt', $application->instructions), 'rd_point_person' => $application->rd_point_person, 'production_date' => $application->production_date, 'termination_date' => $application->termination_date, 'date_created' => $application->date_created, 'date_updated' => $application->date_updated, 'created_by' => $application->created_by, 'updated_by' => $application->updated_by, 'project_name' => $application->project->name, 'point_person' => $row->name);
         $index++;
     }
     return array('data' => $data, 'data_count' => count($data), 'total_count' => $count);
 }
Esempio n. 3
0
 public function actionGetUsers()
 {
     if (!isset($_GET['YII_CSRF_TOKEN'])) {
         throw new CHttpException(400, 'Bad Request');
     } else {
         if ($_GET['YII_CSRF_TOKEN'] != Yii::app()->request->csrfToken) {
             throw new CHttpException(400, 'Bad Request');
         }
     }
     $users = LdapUsers::model()->findAll();
     $data = array();
     foreach ($users as $user) {
         $data[$user->username] = $user->name;
     }
     echo CJSON::encode($data);
 }