ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilAuthContainerDatabase.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 
28 {
37 
39  {
40  $this->Auth_Container_MDB2($dsn);
41  }
42 
43  function getUser($username)
44  {
46 
47  // Fetch the data
48  return parent::getUser($username);
49  }
50 
51  function fetchData($username, $password, $isChallengeResponse=false)
52  {
54 
55  $isSuccessful = parent::fetchData($username, $password, $isChallengeResponse);
56  if ($this->isObserversEnabled)
57  {
58  if ($isSuccessful)
59  {
60  $this->loginObserver($username);
61  }
62  else
63  {
64  $this->failedLoginObserver();
65  }
66  }
67  return $isSuccessful;
68  }
69 
73  static function toUsernameWithoutDomain($username)
74  {
75  // Remove all characters including the last slash or the last backslash
76  // in the username
77  $pos = strrpos($username, '/');
78  $pos2 = strrpos($username, '\\');
79  if ($pos === false || $pos < $pos2)
80  {
81  $pos = $pos2;
82  }
83  if ($pos !== false)
84  {
85  $username = substr($username, $pos + 1);
86  }
87  return $username;
88  }
89 
93  public function setObserversEnabled($boolean)
94  {
95  $this->isObserversEnabled = $boolean;
96  }
97 
101  public function isObserversEnabled()
102  {
104  }
105 
106 
112  public function loginObserver($a_username)
113  {
114  global $ilLog;
115  $ilLog->write(__METHOD__.': logged in as '.$a_username.
116  ', remote:'.$_SERVER['REMOTE_ADDR'].':'.$_SERVER['REMOTE_PORT'].
117  ', server:'.$_SERVER['SERVER_ADDR'].':'.$_SERVER['SERVER_PORT']
118  );
119  }
120 
126  public function failedLoginObserver()
127  {
128  global $ilLog;
129  $ilLog->write(__METHOD__.': login failed'.
130  ', remote:'.$_SERVER['REMOTE_ADDR'].':'.$_SERVER['REMOTE_PORT'].
131  ', server:'.$_SERVER['SERVER_ADDR'].':'.$_SERVER['SERVER_PORT']
132  );
133  }
134 }
135 
136 // END WebDAV: Strip Microsoft Domain Names from logins
137 ?>