source: trunk/phpgwapi/inc/class.auth_nis.inc.php @ 2

Revision 2, 2.8 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2        /**************************************************************************\
3        * eGroupWare API - Auth from NIS                                           *
4        * Authentication based on NIS maps                                         *
5        * by Dylan Adams <dadams@jhu.edu>                                          *
6        * Copyright (C) 2001 Dylan Adams                                           *
7        * -------------------------------------------------------------------------*
8        * This library is part of the eGroupWare API                               *
9        * http://www.egroupware.org/api                                            * 
10        * ------------------------------------------------------------------------ *
11        * This library is free software; you can redistribute it and/or modify it  *
12        * under the terms of the GNU Lesser General Public License as published by *
13        * the Free Software Foundation; either version 2.1 of the License,         *
14        * or any later version.                                                    *
15        * This library is distributed in the hope that it will be useful, but      *
16        * WITHOUT ANY WARRANTY; without even the implied warranty of               *
17        * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     *
18        * See the GNU Lesser General Public License for more details.              *
19        * You should have received a copy of the GNU Lesser General Public License *
20        * along with this library; if not, write to the Free Software Foundation,  *
21        * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA            *
22        \**************************************************************************/
23
24
25        class auth_
26        {
27                function authenticate($username, $passwd)
28                {
29                        $domain = yp_get_default_domain();
30                        if( !empty($GLOBALS['phpgw_info']['server']['nis_domain']) )
31                        {
32                                $domain = $GLOBALS['phpgw_info']['server']['nis_domain'];
33                        }
34
35                        $map = "passwd.byname";
36                        if( !empty($GLOBALS['phpgw_info']['server']['nis_map']) )
37                        {
38                                $map = $GLOBALS['phpgw_info']['server']['nis_map'];
39                        }
40                        $entry = yp_match( $domain, $map, $username );
41
42            /*
43             * we assume that the map is structured in the usual
44             * unix passwd flavor
45             */
46                        $entry_array = explode( ':', $entry );
47                        $stored_passwd = $entry_array[1];
48
49                        $encrypted_passwd = crypt( $passwd, $stored_passwd );
50
51                        return( $encrypted_passwd == $stored_passwd );
52                }
53
54                function change_password($old_passwd, $new_passwd, $account_id = '')
55                {
56                        // can't change passwords unless server runs as root (bad idea)
57                        return( False );
58                }
59
60                function update_lastlogin($account_id, $ip)
61                {
62                        $account_id = get_account_id($account_id);
63
64                        $GLOBALS['phpgw']->db->query("update phpgw_accounts set account_lastloginfrom='"
65                                . "$ip', account_lastlogin='" . time()
66                                . "' where account_id='$account_id'",__LINE__,__FILE__);
67                }
68        }
69?>
Note: See TracBrowser for help on using the repository browser.