ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilAuthContainerDatabase Class Reference

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

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

Public Member Functions

 ilAuthContainerDatabase ($dsn)
 getUser ($username)
 Returns a user assoc array.
 fetchData ($username, $password, $isChallengeResponse=false)
 Get user information from database.
 setObserversEnabled ($boolean)
 Enables/disables the observers of this container.
 isObserversEnabled ()
 Returns true, if the observers of this container are enabled.
 loginObserver ($a_username)
 Called from Auth after successful login.
 failedLoginObserver ()
 Called from Auth after failed login.
- Public Member Functions inherited from Auth_Container_MDB2
 Auth_Container_MDB2 ($dsn)
 Constructor of the container class.
 _connect ($dsn)
 Connect to database by using the given DSN string.
 _prepare ()
 Prepare database connection.
 query ($query)
 Prepare query to the database.
 _setDefaults ()
 Set some default options.
 _parseOptions ($array)
 Parse options passed to the container class.
 _quoteDBFields ()
 Quote the db_fields option to avoid the possibility of SQL injection.
 listUsers ()
 Returns a list of users from the container.
 addUser ($username, $password, $additional="")
 Add user to the storage container.
 removeUser ($username)
 Remove user from the storage container.
 changePassword ($username, $password)
 Change password for user in the storage container.
 supportsChallengeResponse ()
 Determine if this container supports password authentication with challenge response.
 getCryptType ()
 Returns the selected crypt type for this container.
- Public Member Functions inherited from Auth_Container
 Auth_Container ()
 Constructor.
 verifyPassword ($password1, $password2, $cryptType="md5")
 Crypt and verfiy the entered password.
 log ($message, $level=AUTH_LOG_DEBUG)
 Log a message to the Auth log.
- Public Member Functions inherited from ilAuthContainerBase
 loginObserver ($a_username, $a_auth)
 Called after successful login.
 failedLoginObserver ($a_username, $a_auth)
 Called after failed login.
 checkAuthObserver ($a_username, $a_auth)
 Called after check auth requests.
 logoutObserver ($a_username, $a_auth)
 Called after logout.
 supportsCaptchaVerification ()
 Returns whether or not the auth container supports the verification of captchas This should be true for those auth methods, which are available in the default login form.

Static Public Member Functions

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

Private Attributes

 $isObserversEnabled

Additional Inherited Members

- Data Fields inherited from Auth_Container_MDB2
 $options = array()
 $db = null
 $dsn = ''
 $activeUser = ''

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.

Member Function Documentation

ilAuthContainerDatabase::failedLoginObserver ( )

Called from Auth after failed login.

Parameters
stringusername

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

References $ilLog.

Referenced by fetchData().

{
global $ilLog;
$ilLog->write(__METHOD__.': login failed'.
', remote:'.$_SERVER['REMOTE_ADDR'].':'.$_SERVER['REMOTE_PORT'].
', server:'.$_SERVER['SERVER_ADDR'].':'.$_SERVER['SERVER_PORT']
);
}

+ Here is the caller graph for this function:

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

Get user information from database.

This function uses the given username to fetch the corresponding login data from the database table. If an account that matches the passed username and password is found, the function returns true. Otherwise it returns false.

Parameters
stringUsername
stringPassword
booleanIf true password is secured using a md5 hash the frontend and auth are responsible for making sure the container supports challenge response password authentication
Returns
mixed Error object or boolean

Reimplemented from Auth_Container_MDB2.

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

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

{
$isSuccessful = parent::fetchData($username, $password, $isChallengeResponse);
if ($this->isObserversEnabled)
{
if ($isSuccessful)
{
$this->loginObserver($username);
}
else
{
}
}
return $isSuccessful;
}

+ Here is the call graph for this function:

ilAuthContainerDatabase::getUser (   $username)

Returns a user assoc array.

Containers which want should overide this

Parameters
stringThe username

Reimplemented from Auth_Container.

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

References toUsernameWithoutDomain().

{
// Fetch the data
return parent::getUser($username);
}

+ Here is the call graph for this function:

ilAuthContainerDatabase::ilAuthContainerDatabase (   $dsn)

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

References Auth_Container_MDB2\$dsn, and Auth_Container_MDB2\Auth_Container_MDB2().

{
}

+ Here is the call graph for this function:

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:

ilAuthContainerDatabase::loginObserver (   $a_username)

Called from Auth after successful login.

Parameters
stringusername

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

References $ilLog.

Referenced by fetchData().

{
global $ilLog;
$ilLog->write(__METHOD__.': logged in as '.$a_username.
', remote:'.$_SERVER['REMOTE_ADDR'].':'.$_SERVER['REMOTE_PORT'].
', server:'.$_SERVER['SERVER_ADDR'].':'.$_SERVER['SERVER_PORT']
);
}

+ Here is the caller graph for this function:

ilAuthContainerDatabase::setObserversEnabled (   $boolean)

Enables/disables the observers of this container.

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

References isObserversEnabled().

{
$this->isObserversEnabled = $boolean;
}

+ Here is the call graph for this function:

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().

{
// Remove all characters including the last slash or the last backslash
// in the username
$pos = strrpos($username, '/');
$pos2 = strrpos($username, '\\');
if ($pos === false || $pos < $pos2)
{
$pos = $pos2;
}
if ($pos !== false)
{
$username = substr($username, $pos + 1);
}
return $username;
}

+ Here is the caller graph for this function:

Field Documentation

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: