koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] CVS: koha/C4 Auth.pm,1.29,1.30


From: Paul POULAIN
Subject: [Koha-cvs] CVS: koha/C4 Auth.pm,1.29,1.30
Date: Thu, 04 Mar 2004 08:49:11 -0800

Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18481/C4

Modified Files:
        Auth.pm 
Log Message:
adding LDAP auth.
Introduce a new Perl dependency Net:LDAP

Index: Auth.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Auth.pm,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -r1.29 -r1.30
*** Auth.pm     6 Aug 2003 12:38:27 -0000       1.29
--- Auth.pm     4 Mar 2004 16:49:09 -0000       1.30
***************
*** 29,32 ****
--- 29,34 ----
  use C4::Interface::CGI::Output;
  use C4::Circulation::Circ2;  # getpatroninformation
+ use Net::LDAP;
+ use Net::LDAP qw(:all);
  
  use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
***************
*** 46,50 ****
    my $query = new CGI;
  
!   my ($template, $borrowernumber, $cookie)
      = get_template_and_user({template_name   => "opac-main.tmpl",
                               query           => $query,
--- 48,52 ----
    my $query = new CGI;
  
!   my ($template, $borrowernumber, $cookie) 
      = get_template_and_user({template_name   => "opac-main.tmpl",
                               query           => $query,
***************
*** 178,182 ****
  
  The login page is provided using a HTML::Template, which is set in the
! systempreferences table or at the top of this file. The variable C<$type> 
  selects which template to use, either the opac or the intranet 
  authentification template.
--- 180,184 ----
  
  The login page is provided using a HTML::Template, which is set in the
! systempreferences table or at the top of this file. The variable C<$type>
  selects which template to use, either the opac or the intranet 
  authentification template.
***************
*** 348,351 ****
--- 350,383 ----
  #
        my ($dbh, $userid, $password) = @_;
+ # LDAP
+       my $sth=$dbh->prepare("select value from systempreferences where 
variable=?");
+       $sth->execute("ldapserver");
+       my $ldapserver = C4::Context->preferences('ldapserver');
+       if ($ldapserver) {
+               my $ldapinfos = C4::Context->preferences('ldapinfos');
+               my %bindargs;
+               my $nom  = "uid=$userid, $ldapinfos";
+               my $db = Net::LDAP->new( $ldapserver );
+               $bindargs{dn}=$nom;
+               $bindargs{password}=$password;
+               my $res =$db->bind(%bindargs);
+               if($res->code) {
+               # auth refused
+                       return 0;
+               } else {
+               #get the cardnumber
+               my $sth=$dbh->prepare("select cardnumber from borrowers where 
userid=?");
+               $sth->execute($userid);
+               if ($sth->rows) {
+                       my $cardnumber = $sth->fetchrow;
+                       #we have the cardnumber
+                       return 1,$cardnumber;
+               }
+               if ($userid eq C4::Context->config('user') && $password eq 
C4::Context->config('pass')) {
+                       # Koha superuser account
+                       return 2;
+               }
+       }
+ # INTERNAL AUTH
        my $sth=$dbh->prepare("select password,cardnumber from borrowers where 
userid=?");
        $sth->execute($userid);
***************
*** 376,381 ****
  }
  
- 
- 
  sub getuserflags {
      my $cardnumber=shift;
--- 408,411 ----
***************
*** 406,411 ****
        # Super User Account from /etc/koha.conf
        $flags->{'superlibrarian'}=1;
!     }
!     if ($userid eq 'demo' && C4::Context->config('demo')) {
        # Demo user that can do "anything" (demo=1 in /etc/koha.conf)
        $flags->{'superlibrarian'}=1;
--- 436,441 ----
        # Super User Account from /etc/koha.conf
        $flags->{'superlibrarian'}=1;
!      }
!      if ($userid eq 'demo' && C4::Context->config('demo')) {
        # Demo user that can do "anything" (demo=1 in /etc/koha.conf)
        $flags->{'superlibrarian'}=1;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]