ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilAuthContainerDatabase Class Reference

Storage driver for fetching login data from a database. More...

+ Inheritance diagram for ilAuthContainerDatabase:
+ Collaboration diagram for ilAuthContainerDatabase:

Public Member Functions

 __construct ($dsn)
 
 getUser ($username)
 
 fetchData ($username, $password, $isChallengeResponse=false)
 
 setObserversEnabled ($boolean)
 Enables/disables the observers of this container. More...
 
 isObserversEnabled ()
 Returns true, if the observers of this container are enabled. More...
 
 loginObserver ($a_username)
 Called from Auth after successful login. More...
 
 failedLoginObserver ()
 Called from Auth after failed login. More...
 

Static Public Member Functions

static toUsernameWithoutDomain ($username)
 Static function removes Microsoft domain name from username. More...
 

Private Attributes

 $isObserversEnabled
 

Detailed Description

Storage driver for fetching login data from a database.

This driver strips leading Microsoft Windows domain names from the user name.

For example: hsw hsw/wrandels and wrandels refer all to the login name wrandels.

This storage driver can use all databases which are supported by the PEAR DB abstraction layer to fetch login data.

Usage note: If you use an ilAuthContainerMDB2 object as the container for an Auth object you MUST call setEnableObservers(true) on the ilAuthContainerMDB2 object. The observers are used to perform actions depending on the success or failure of a login attempt.

Author
Werner Randelshofer, Lucerne University of Applied Sciences and Arts, werne.nosp@m.r.ra.nosp@m.ndels.nosp@m.hofe.nosp@m.r@hsl.nosp@m.u.ch
Version
$Id$
Deprecated:
Will be replace by ilAuthContainerMDB in Services/Database

Definition at line 27 of file class.ilAuthContainerDatabase.php.

Constructor & Destructor Documentation

◆ __construct()

ilAuthContainerDatabase::__construct (   $dsn)

Definition at line 38 of file class.ilAuthContainerDatabase.php.

39  {
40  $this->Auth_Container_MDB2($dsn);
41  }

Member Function Documentation

◆ failedLoginObserver()

ilAuthContainerDatabase::failedLoginObserver ( )

Called from Auth after failed login.

Parameters
stringusername

Definition at line 126 of file class.ilAuthContainerDatabase.php.

References $_SERVER, and $ilLog.

Referenced by fetchData().

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  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
+ Here is the caller graph for this function:

◆ fetchData()

ilAuthContainerDatabase::fetchData (   $username,
  $password,
  $isChallengeResponse = false 
)

Definition at line 51 of file class.ilAuthContainerDatabase.php.

References failedLoginObserver(), isObserversEnabled(), loginObserver(), and toUsernameWithoutDomain().

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  }
loginObserver($a_username)
Called from Auth after successful login.
static toUsernameWithoutDomain($username)
Static function removes Microsoft domain name from username.
isObserversEnabled()
Returns true, if the observers of this container are enabled.
failedLoginObserver()
Called from Auth after failed login.
+ Here is the call graph for this function:

◆ getUser()

ilAuthContainerDatabase::getUser (   $username)

Definition at line 43 of file class.ilAuthContainerDatabase.php.

References toUsernameWithoutDomain().

44  {
46 
47  // Fetch the data
48  return parent::getUser($username);
49  }
static toUsernameWithoutDomain($username)
Static function removes Microsoft domain name from username.
+ Here is the call graph for this function:

◆ isObserversEnabled()

ilAuthContainerDatabase::isObserversEnabled ( )

Returns true, if the observers of this container are enabled.

Definition at line 101 of file class.ilAuthContainerDatabase.php.

References $isObserversEnabled.

Referenced by fetchData(), and setObserversEnabled().

+ Here is the caller graph for this function:

◆ loginObserver()

ilAuthContainerDatabase::loginObserver (   $a_username)

Called from Auth after successful login.

Parameters
stringusername

Definition at line 112 of file class.ilAuthContainerDatabase.php.

References $_SERVER, and $ilLog.

Referenced by fetchData().

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  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
+ Here is the caller graph for this function:

◆ setObserversEnabled()

ilAuthContainerDatabase::setObserversEnabled (   $boolean)

Enables/disables the observers of this container.

Definition at line 93 of file class.ilAuthContainerDatabase.php.

References isObserversEnabled().

94  {
95  $this->isObserversEnabled = $boolean;
96  }
isObserversEnabled()
Returns true, if the observers of this container are enabled.
+ Here is the call graph for this function:

◆ toUsernameWithoutDomain()

static ilAuthContainerDatabase::toUsernameWithoutDomain (   $username)
static

Static function removes Microsoft domain name from username.

Definition at line 73 of file class.ilAuthContainerDatabase.php.

Referenced by fetchData(), and getUser().

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  }
+ Here is the caller graph for this function:

Field Documentation

◆ $isObserversEnabled

ilAuthContainerDatabase::$isObserversEnabled
private

Definition at line 36 of file class.ilAuthContainerDatabase.php.

Referenced by isObserversEnabled().


The documentation for this class was generated from the following file: