XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
authfactory.php
Go to the documentation of this file.
1 <?php
21 defined('XOOPS_ROOT_PATH') or die('Restricted access');
22 
32 {
42  function &getAuthConnection($uname)
43  {
44  static $auth_instance;
45  if (!isset($auth_instance)) {
46  $config_handler =& xoops_gethandler('config');
47  $authConfig = $config_handler->getConfigsByCat(XOOPS_CONF_AUTH);
48 
49  include_once $GLOBALS['xoops']->path('class/auth/auth.php');
50 
51  if (empty($authConfig['auth_method'])) { // If there is a config error, we use xoops
52  $xoops_auth_method = 'xoops';
53  } else {
54  $xoops_auth_method = $authConfig['auth_method'];
55  }
56  // Verify if uname allow to bypass LDAP auth
57  if (in_array($uname, $authConfig['ldap_users_bypass'])) {
58  $xoops_auth_method = 'xoops';
59  }
60 
61  $ret = include_once $GLOBALS['xoops']->path('class/auth/auth_' . $xoops_auth_method . '.php');
62  if ($ret == false) {
63  return false;
64  }
65 
66  $class = 'XoopsAuth' . ucfirst($xoops_auth_method);
67  if (!class_exists($class)) {
68  $GLOBALS['xoopsLogger']->triggerError($class, _XO_ER_CLASSNOTFOUND, __FILE__, __LINE__, E_USER_ERROR );
69  return false;
70  }
71  switch ($xoops_auth_method) {
72  case 'xoops':
74  break;
75  case 'ldap':
76  $dao = null;
77  break;
78  case 'ads':
79  $dao = null;
80  break;
81  }
82  $auth_instance = new $class($dao);
83  }
84  return $auth_instance;
85  }
86 }
87 
88 ?>