Posted by lindsaym on Wed 2nd Dec 11:33 (modification of post by lindsaym view diff)
View followups from lindsaym | diff | download | new post
- function login_user( $username, $passphrase, $from_cookie = false ) {
- // perform a login check for username and passphrase
- // returns the user's user_id
- $username = $this->checkAlphaNum($username);
- $pass = $from_cookie? $this->checkSlashes($passphrase) : $this->checkSlashes($this->encval($passphrase));
- #XXX: START LDAP EDIT ML.11/23/2009
- //CHECK THE PROTECTED USER ARRAY AGAINST THE SUBMITTED USER FORM
- //If the user is in the protected array the ALL LDAP/AD functions will be skipped
- // and normal ZT DB authenication will be done
- foreach ($this->ldap_to_ZT_protected_users as $value){
- if($value == $username){
- $userSkip = TRUE;
- break;
- }else{
- $userSkip = FALSE;
- }
- }
- //CHECK TO SEE IF LDAP AUTH IS SET AND THE USERSKIP VAR IS FALSE
- if ($this->LDAP_login && !$userSkip){
- ldapConnect($this->ldap_server, $this->ldap_port, $this->ldap_tls_enable);
- #THIS IS WHERE THE LDAP AUTH AND REPLICATION HAPPENS
- //Create the user's RDN to bind to
- if($this->ADcompat){
- //$userDN = $username . "@" . $this->ldap_AD_domain;
- $userDN = $this->ldap_user_dn_prefix . "=" . $username . "@" . $this->ldap_AD_domain . "," . $this->ldap_user_dn;
- }else{
- $userDN = $this->ldap_user_dn_prefix . "=" . $username . "," . $this->ldap_user_dn;
- }
- /*********** COMMENT OUT TIL END BLOCK FOR GROUP BYPASS ***********************/
- $validUser = ldap_auth_user($userDN, $passphrase, $this->ldap_failover_support); //auth the user agianst LDAP return 0 on fail
- if($validUser == 1){
- //Verify group membership or return 0
- if(ldap_verify_group($userDN, $this->ldap_base_dn, $this->ldap_requiredGroup_dn, $this->ldap_groupMemberSearch)){
- //sync the ldap group membership and usertable. return the ldap response array
- }else{
- ldapClose();
- return 0; //not a group member denied and not replicated
- }
- }elseif($validUser == 999){ //if 999 is returned then we have hit a failover mark
- //AUTH AGAINST ZT DB
- $query = "select user_id from ".$this->table_users
- ." where login = '$username' and passphrase = $pass and active > 0";
- $user_id = $this->db_get($query);
- $this->addDebug("zentrack.class.php:login_user($user_id)",$query,2);
- if( $user_id ) { $this->getUser($user_id); };
- return($user_id);
- }else{
- //insert the access denied message here
- ldapClose();
- return 0;
- }
- //TIME FOR HOUSE CLEANING, DELETE OR MARK USERS INACTIVE IN ZT DB IF NOT IN LDAP GROUP
- //RELEASE THE LDAP CONNECTION, ALL DONE
- ldapClose();
- //END BLOCK */
- /*********** UN COMMENT FOR GROUP BYPASS **********************
- if(!ldap_auth_user($userDN, $passphrase, $this->ldap_failover_support)){ //auth the user agianst LDAP return 0 on fail
- //insert the access denied message here
- ldapClose();
- return 0;
- }
- //RELEASE THE LDAP CONNECTION, ALL DONE
- ldapClose();
- /*************************************************************/
- }
- #XXX: END LDAP EDIT ML.11/23/2009
- $query = "select user_id from ".$this->table_users
- ." where login = '$username' and passphrase = $pass and active > 0";
- $user_id = $this->db_get($query);
- $this->addDebug("zentrack.class.php:login_user($user_id)",$query,2);
- if( $user_id ) { $this->getUser($user_id); };
- return($user_id);
- }
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.