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

(-)a/C4/Auth_with_ldap.pm (-3 / +39 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 225-231 sub checkpw_ldap { Link Here
225
        )->store;
227
        )->store;
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(
231
            {
232
                borrowernumber => $borrowernumber,
233
                categorycode   => $borrower{'categorycode'}
234
            }
235
        );
236
237
        # Send welcome email if enabled
238
        if ( $config{welcome} ) {
239
            my $emailaddr = $patron->notice_email_address;
240
241
            # if we manage to find a valid email address, send notice
242
            if ($emailaddr) {
243
                my $letter = C4::Letters::GetPreparedLetter(
244
                    module      => 'members',
245
                    letter_code => 'WELCOME',
246
                    branchcode  => $patron->branchcode,
247
                    lang        => $patron->lang || 'default',
248
                    tables      => {
249
                        'branches'  => $patron->branchcode,
250
                        'borrowers' => $patron->borrowernumber,
251
                    },
252
                    want_librarian => 1,
253
                ) or return;
254
255
                my $message_id = C4::Letters::EnqueueLetter(
256
                    {
257
                        letter                 => $letter,
258
                        borrowernumber         => $patron->id,
259
                        to_address             => $emailaddr,
260
                        message_transport_type => 'email'
261
                    }
262
                );
263
            }
264
        }
229
   } else {
265
   } else {
230
        return 0;   # B2, D2
266
        return 0;   # B2, D2
231
    }
267
    }
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 -->
544
    <user>cn=Manager,dc=metavore,dc=com</user>             <!-- DN, if not anonymous -->
509
    <pass>metavore</pass>          <!-- password, if not anonymous -->
545
    <pass>metavore</pass>          <!-- password, if not anonymous -->
510
    <replicate>1</replicate>       <!-- add new users from LDAP to Koha database -->
546
    <replicate>1</replicate>       <!-- add new users from LDAP to Koha database -->
547
    <welcome>1</welcome>           <!-- send new users the welcome email when added via replicate -->
511
    <update>1</update>             <!-- update existing users in Koha database -->
548
    <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
549
    <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 -->
550
                                        password comparison, e.g., to use Active Directory -->
514
- 

Return to bug 30646