• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

classes/class.ilAuthUtils.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00034 class ilAuthUtils
00035 {
00036         function _getAuthModeOfUser($a_username,$a_password,$a_db_handler = '')
00037         {
00038                 global $ilDB;
00039                 
00040                 $db =& $ilDB;
00041                 
00042                 if ($a_db_handler != '')
00043                 {
00044                         $db =& $a_db_handler;
00045                 }
00046                 
00047                 $q = "SELECT auth_mode FROM usr_data WHERE ".
00048                          "login = ".$ilDB->quote($a_username)." AND ".
00049                          "passwd = ".$ilDB->quote(md5($a_password))."";
00050                 $r = $this->db->query($q);
00051                 
00052                 $row = $r->fetchRow(DB_FETCHMODE_OBJECT);
00053                 
00054                 return ilAuthUtils::_getAuthMode($row->auth_mode,$db);
00055         }
00056         
00057         function _getAuthMode($a_auth_mode,$a_db_handler = '')
00058         {
00059                 global $ilDB;
00060                 
00061                 $db =& $ilDB;
00062                 
00063                 if ($a_db_handler != '')
00064                 {
00065                         $db =& $a_db_handler;
00066                 }
00067 
00068                 switch ($a_auth_mode)
00069                 {
00070                         case "local":
00071                                 return AUTH_LOCAL;
00072                                 break;
00073                                 
00074                         case "ldap":
00075                                 return AUTH_LDAP;
00076                                 break;
00077                                 
00078                         case "radius":
00079                                 return AUTH_RADIUS;
00080                                 break;
00081                                 
00082                         case "script":
00083                                 return AUTH_SCRIPT;
00084                                 break;
00085                                 
00086                         case "shibboleth":
00087                                 return AUTH_SHIBBOLETH;
00088                                 break;
00089                                 
00090                         default:
00091                                 $q = "SELECT value FROM settings WHERE ".
00092                                          "keyword='auth_mode'";
00093                                 $r = $db->query($q);
00094                                 $row = $r->fetchRow();
00095                                 return $row[0];
00096                                 break;  
00097                 }
00098         }
00099         
00100         function _getAuthModeName($a_auth_key)
00101         {
00102                 global $ilias;
00103 
00104                 switch ($a_auth_key)
00105                 {
00106                         case AUTH_LOCAL:
00107                                 return "local";
00108                                 break;
00109                                 
00110                         case AUTH_LDAP:
00111                                 return "ldap";
00112                                 break;
00113                                 
00114                         case AUTH_RADIUS:
00115                                 return "radius";
00116                                 break;
00117                                 
00118                         case AUTH_SCRIPT:
00119                                 return "script";
00120                                 break;
00121                                 
00122                         case AUTH_SHIBBOLETH:
00123                                 return "shibboleth";
00124                                 break;
00125                                 
00126                         default:
00127                                 return "default";
00128                                 break;  
00129                 }
00130         }
00131         
00132         function _getActiveAuthModes()
00133         {
00134                 global $ilias;
00135                 
00136                 $modes = array(
00137                                                 'default'       => $ilias->getSetting("auth_mode"),
00138                                                 'local'         => AUTH_LOCAL
00139                                                 );
00140                 
00141                 if ($ilias->getSetting("ldap_active")) $modes['ldap'] = AUTH_LDAP;
00142                 if ($ilias->getSetting("radius_active")) $modes['radius'] = AUTH_RADIUS;
00143                 if ($ilias->getSetting("shibboleth_active")) $modes['shibboleth'] = AUTH_SHIBBOLETH;
00144                 if ($ilias->getSetting("script_active")) $modes['script'] = AUTH_SCRIPT;
00145 
00146                 return $modes;
00147         }
00148         
00149 }
00150 ?>

Generated on Fri Dec 13 2013 10:18:26 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1