Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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 ?>