View | Details | Raw Unified | Return to bug 30646
Collapse All | Expand All

(-)a/C4/Auth_with_ldap.pm (-2 / +35 lines)
Lines 23-28 use Carp qw( croak ); Link Here
23
use C4::Context;
23
use C4::Context;
24
use C4::Members::Messaging;
24
use C4::Members::Messaging;
25
use C4::Auth qw( checkpw_internal );
25
use C4::Auth qw( checkpw_internal );
26
use C4::Letters qw( GetPreparedLetter EnqueueLetter );
26
use Koha::Patrons;
27
use Koha::Patrons;
27
use Koha::AuthUtils qw( hash_password );
28
use Koha::AuthUtils qw( hash_password );
28
use Net::LDAP;
29
use Net::LDAP;
Lines 74-80 if(defined $ldap->{categorycode_mapping}) { Link Here
74
my %config = (
75
my %config = (
75
    anonymous => defined ($ldap->{anonymous_bind}) ? $ldap->{anonymous_bind} : 1,
76
    anonymous => defined ($ldap->{anonymous_bind}) ? $ldap->{anonymous_bind} : 1,
76
    replicate => defined($ldap->{replicate}) ? $ldap->{replicate} : 1,  #    add from LDAP to Koha database for new user
77
    replicate => defined($ldap->{replicate}) ? $ldap->{replicate} : 1,  #    add from LDAP to Koha database for new user
77
       update => defined($ldap->{update}   ) ? $ldap->{update}    : 1,  # update from LDAP to Koha database for existing user
78
    welcome   => defined($ldap->{welcome}) ? $ldap->{welcome} : 0,  #    send welcome notice when patron is added via replicate
79
    update    => defined($ldap->{update}) ? $ldap->{update} : 1,  # update from LDAP to Koha database for existing user
78
);
80
);
79
81
80
sub description {
82
sub description {
Lines 226-231 sub checkpw_ldap { Link Here
226
        die "Insert of new patron failed" unless $patron;
228
        die "Insert of new patron failed" unless $patron;
227
        $borrowernumber = $patron->borrowernumber;
229
        $borrowernumber = $patron->borrowernumber;
228
        C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { borrowernumber => $borrowernumber, categorycode => $borrower{'categorycode'} } );
230
        C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { borrowernumber => $borrowernumber, categorycode => $borrower{'categorycode'} } );
231
232
        # Send welcome email if enabled
233
        if ( $config{welcome} ) {
234
            my $emailaddr = $patron->notice_email_address;
235
236
            # if we manage to find a valid email address, send notice
237
            if ($emailaddr) {
238
                eval {
239
                    my $letter = GetPreparedLetter(
240
                        module      => 'members',
241
                        letter_code => 'WELCOME',
242
                        branchcode  => $patron->branchcode,,
243
                        lang        => $patron->lang || 'default',
244
                        tables      => {
245
                            'branches'  => $patron->branchcode,
246
                            'borrowers' => $patron->borrowernumber,
247
                        },
248
                        want_librarian => 1,
249
                    ) or return;
250
251
                    my $message_id = EnqueueLetter(
252
                        {
253
                            letter                 => $letter,
254
                            borrowernumber         => $patron->id,
255
                            to_address             => $emailaddr,
256
                            message_transport_type => 'email'
257
                        }
258
                    );
259
                };
260
            }
261
        }
229
   } else {
262
   } else {
230
        return 0;   # B2, D2
263
        return 0;   # B2, D2
231
    }
264
    }
Lines 508-513 Example XML stanza for LDAP configuration in KOHA_CONF. Link Here
508
    <user>cn=Manager,dc=metavore,dc=com</user>             <!-- DN, if not anonymous -->
541
    <user>cn=Manager,dc=metavore,dc=com</user>             <!-- DN, if not anonymous -->
509
    <pass>metavore</pass>          <!-- password, if not anonymous -->
542
    <pass>metavore</pass>          <!-- password, if not anonymous -->
510
    <replicate>1</replicate>       <!-- add new users from LDAP to Koha database -->
543
    <replicate>1</replicate>       <!-- add new users from LDAP to Koha database -->
544
    <welcome>1</welcome>           <!-- send new users the welcome email when added via replicate -->
511
    <update>1</update>             <!-- update existing users in Koha database -->
545
    <update>1</update>             <!-- update existing users in Koha database -->
512
    <auth_by_bind>0</auth_by_bind> <!-- set to 1 to authenticate by binding instead of
546
    <auth_by_bind>0</auth_by_bind> <!-- set to 1 to authenticate by binding instead of
513
                                        password comparison, e.g., to use Active Directory -->
547
                                        password comparison, e.g., to use Active Directory -->
514
- 

Return to bug 30646