commit 15d14433d57f1c3941eec4e324a22858c8dba96c
parent 0fb80b95b643d29e92247c819aec7289f7e4d617
Author: dankert <devnull@localhost>
Date: Sat, 27 Jan 2007 01:16:36 +0100
Neuer Loginmechanismus: "authdb"
Diffstat:
1 file changed, 33 insertions(+), 4 deletions(-)
diff --git a/objectClasses/User.class.php b/objectClasses/User.class.php
@@ -20,7 +20,10 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// ---------------------------------------------------------------------------
// $Log$
-// Revision 1.18 2007-01-21 22:20:12 dankert
+// Revision 1.19 2007-01-27 00:16:36 dankert
+// Neuer Loginmechanismus: "authdb"
+//
+// Revision 1.18 2007/01/21 22:20:12 dankert
// Erweiterungen bei LDAP-Zugriff, Auslagerung von LDAP-Befehlen in eigene Klasse.
//
// Revision 1.17 2007/01/20 15:20:31 dankert
@@ -521,8 +524,7 @@ SQL
$res_user = $db->query( $sql->query );
$check = false;
- $authType = $conf['security']['auth']['type']; // Entweder 'ldap' oder 'database'
- $autoAdd = $conf['ldap']['search']['add']; // Einstellung, ob automatisches Hinzufügen.
+ $authType = $conf['security']['auth']['type']; // Entweder 'ldap', 'authdb' oder 'database'
if ( $res_user->numRows() == 1 )
{
@@ -533,11 +535,17 @@ SQL
$check = true;
$autoAdd = false; // Darf nicht hinzugefügt werden, da schon vorhanden.
}
- elseif( $res_user->numRows() == 0 && $authType == 'ldap' && $autoAdd )
+ elseif( $res_user->numRows() == 0 && $authType == 'ldap' && $conf['ldap']['search']['add'] )
{
// Benutzer noch nicht in der Datenbank vorhanden.
// Falls ein LDAP-Account gefunden wird, wird dieser übernommen.
+ $check = true;
+ $autoAdd = true;
+ }
+ elseif( $res_user->numRows() == 0 && $authType == 'authdb' && $conf['security']['authdb']['add'] )
+ {
$check = true;
+ $autoAdd = true;
}
if ( $check )
@@ -613,6 +621,27 @@ SQL
return false;
}
}
+ elseif( $authType == 'authdb' )
+ {
+ $authdb = new DB( $conf['security']['authdb'] );
+ $sql = new Sql( $conf['security']['authdb']['sql'] );
+ $sql->setString('username',$this->name);
+ $sql->setString('password',$password);
+ $res = $authdb->query($sql->query);
+ $ok = ($res->numRows() >= 1);
+
+ if ( $ok && $autoAdd )
+ {
+ // Falls die Authentifizierung geklappt hat, wird der
+ // Benutzername in der eigenen Datenbank eingetragen.
+ $this->fullname = $this->name;
+ $this->add();
+ $this->save();
+ }
+ // noch nicht implementiert: $authdb->close();
+
+ return $ok;
+ }
else
{
die( 'unknown auth-type: '.$authType );