ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilAuthContainerMDB2.php
Go to the documentation of this file.
1 <?php
2 // BEGIN WebDAV: Strip Microsoft Domain Names from logins
3 require_once 'Auth/Container.php';
4 require_once 'Auth/Container/MDB2.php';
5 
26 {
35 
36  function ilAuthContainerMDB2($dsn)
37  {
38  $this->Auth_Container_MDB2($dsn);
39  }
40 
41  function getUser($username)
42  {
43  $username = ilAuthContainerMDB2::toUsernameWithoutDomain($username);
44 
45  // Fetch the data
46  return parent::getUser($username);
47  }
48 
49  function fetchData($username, $password, $isChallengeResponse=false)
50  {
51  $username = ilAuthContainerMDB2::toUsernameWithoutDomain($username);
52 
53  $isSuccessful = parent::fetchData($username, $password, $isChallengeResponse);
54  if ($this->isObserversEnabled)
55  {
56  if ($isSuccessful)
57  {
58  $this->loginObserver($username);
59  }
60  else
61  {
62  $this->failedLoginObserver();
63  }
64  }
65  return $isSuccessful;
66  }
67 
71  static function toUsernameWithoutDomain($username)
72  {
73  // Remove all characters including the last slash or the last backslash
74  // in the username
75  $pos = strrpos($username, '/');
76  $pos2 = strrpos($username, '\\');
77  if ($pos === false || $pos < $pos2)
78  {
79  $pos = $pos2;
80  }
81  if ($pos !== false)
82  {
83  $username = substr($username, $pos + 1);
84  }
85  return $username;
86  }
87 
91  public function setObserversEnabled($boolean)
92  {
93  $this->isObserversEnabled = $boolean;
94  }
95 
99  public function isObserversEnabled()
100  {
102  }
103 
104 
110  public function loginObserver($a_username)
111  {
112  global $ilLog;
113  $ilLog->write(__METHOD__.': logged in as '.$a_username.
114  ', remote:'.$_SERVER['REMOTE_ADDR'].':'.$_SERVER['REMOTE_PORT'].
115  ', server:'.$_SERVER['SERVER_ADDR'].':'.$_SERVER['SERVER_PORT']
116  );
117  }
118 
124  public function failedLoginObserver()
125  {
126  global $ilLog;
127  $ilLog->write(__METHOD__.': login failed'.
128  ', remote:'.$_SERVER['REMOTE_ADDR'].':'.$_SERVER['REMOTE_PORT'].
129  ', server:'.$_SERVER['SERVER_ADDR'].':'.$_SERVER['SERVER_PORT']
130  );
131  }
132 }
133 
134 // END WebDAV: Strip Microsoft Domain Names from logins
135 ?>