Re: [phplib] Session und login password From: Kirk Ismay (captain <email protected>)
Date: 05/24/00

Joern Muehlencord wrote:
>
> Hi!
>
> How can make the linux system password and the phplib session password
> work together.
> That means that the user uses the same password for system login and for
> session authentification. If he changes the one password - the other one
> should be changed automaticly (may be not on the fly but during a hourly
> chron job)
> Any ideas?
> --
> The box said "Requires Win95, NT, or better," and so I installed Linux.

I work for a regional ISP and have a solved a similar problem. We solved
it by:

1. Users are entered into the database first through intranet server.
The user table has a boolean flag for whether or not its been modified.
2. A Perl script on our public web server queries our database every 2
minutes (run by cron).
3. The perl script adds new users to server using adduser, then sets the
modified flag to false. It also stores the value of the crypted password
back to the database.

I then use the following function in my Auth class:

  function auth_validatelogin() {
    global $username, $password;

    if(isset($username)) {
      $this->auth["uname"]=$username; ## This provides access for
"loginform.ihtml"
    }
    
    $uid = false;
    
    $this->db->query(sprintf("select user_id, crypt_password, perms ".
                             " from %s ".
                             " where username = '%s' ",
                          $this->database_table,
                          addslashes($username)));

    if ($this->db->next_record()) {
       $uid = $this->db->f("user_id");
       $pass = $this->db->f('crypt_password');
       $crypted = crypt ($password, substr($pass, 0, 2));
       if ($crypted == $pass) {
          $this->auth["perm"] = $this->db->f("perms");
          return $uid;
       } else {
          return FALSE;
       }
    }
    return $uid;
  }

-- 
Sincerely, Kirk Ismay
________________________________________________________________________
The Net Idea Telecommunications Inc	       Support: tech <email protected>
101-625 Front Street,			       Sales:  sales <email protected>
Nelson BC, V1L 4B6
Phone: 352-3512 Fax: 352-9780		 Open Monday to Friday 9:30-5:30
Toll Free: 1-888-246-4222		    10:00 - 4:00 on Saturdays
________________________________________________________________________

--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>