~ubuntu-branches/debian/squeeze/sympa/squeeze

« back to all changes in this revision

Viewing changes to src/Ldap.pm

  • Committer: Bazaar Package Importer
  • Author(s): Christian Perrier
  • Date: 2007-01-20 18:09:28 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070120180928-0e42mbwg87mlo44y
Tags: 5.2.3-1.2
* Non-maintainer upload to re-fix l10n issues
* As debconf-updatepo was not run in previous versions, the French
  translation was outdated. Hence fix it.
* Remove several duplicate spaces in the debconf templates

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Ldap.pm - This module includes most LDAP-related functions
2
 
# RCS Identication ; $Revision: 1.9 $ ; $Date: 2004/03/03 15:06:02 $ 
 
2
# RCS Identication ; $Revision: 1.14 $ ; $Date: 2006/01/05 14:23:29 $ 
3
3
#
4
4
# Sympa - SYsteme de Multi-Postage Automatique
5
5
# Copyright (c) 1997, 1998, 1999, 2000, 2001 Comite Reseau des Universites
28
28
@ISA = qw(Exporter);
29
29
@EXPORT = qw(%Ldap);
30
30
 
31
 
my @valid_options = qw(host port suffix filter scope);
 
31
my @valid_options = qw(host port suffix filter scope bind_dn bind_password);
 
32
my  @required_options = qw(host port suffix filter scope);
32
33
 
33
34
my %valid_options = ();
34
35
map { $valid_options{$_}++; } @valid_options;
35
36
 
 
37
my %required_options = ();
 
38
map { $required_options{$_}++; } @required_options;
 
39
 
36
40
my %Default_Conf =
37
41
    (   'host'=> undef,
38
42
        'port' => undef,
39
43
        'suffix' => undef,
40
44
        'filter' => undef,
41
 
        'scope' => undef
 
45
        'scope' => undef,
 
46
        'bind_dn' => undef,
 
47
        'bind_password' => undef
42
48
   );
43
49
 
44
50
%Ldap = ();
77
83
 
78
84
    ## Check if we have unknown values.
79
85
    foreach $i (sort keys %o) {
80
 
        next if ($valid_options{$i});
81
 
        &Log::do_log('err',"Line %d, unknown field: %s \n", $o{$i}[1], $i);
82
 
        $config_err++;
 
86
        $Ldap{$i} = $o{$i}[0] || $Default_Conf{$i};
 
87
        
 
88
        unless ($valid_options{$i}) {
 
89
            &Log::do_log('err',"Line %d, unknown field: %s \n", $o{$i}[1], $i);
 
90
            $config_err++;
 
91
        }
83
92
    }
84
93
    ## Do we have all required values ?
85
 
    foreach $i (keys %valid_options) {
 
94
    foreach $i (keys %required_options) {
86
95
        unless (defined $o{$i} or defined $Default_Conf{$i}) {
87
96
            &Log::do_log('err',"Required field not found : %s\n", $i);
88
97
            $config_err++;
89
98
            next;
90
99
        }
91
 
        $Ldap{$i} = $o{$i}[0] || $Default_Conf{$i};
92
 
        
93
100
    }
94
101
 return %Ldap;
95
102
}
103
110
 
104
111
    ##To record owner's and editor's email and gecos
105
112
    ## !! STRUCTURE LDAP A REVOIR
106
 
    foreach my $element (@{$list->{'admin'}{'owner'}}){
 
113
    my $owners = $list->get_owners();
 
114
    foreach my $element (@{$owners}) {
107
115
        next unless (defined $element->{'email'});
108
116
        if (ref($element->{'email'})) {
109
117
            push(@owner_emails, @{$element->{'email'}});
146
154
    return undef
147
155
        unless &delete_list($directory, $list, $ldap);
148
156
        
149
 
    my $list_email = "$list->{'name'}".'@'."$list->{'admin'}{'host'}"; 
 
157
    my $list_email = $list->get_list_address();
150
158
    my $dn = "cn=$list_email,$Conf{'ldap_export'}{$directory}{'suffix'}";
151
159
 
152
160
    my $total =  $list->get_total() || 0;
227
235
    }
228
236
    
229
237
    ##To create the dn and delete this entry
230
 
    my $list_email = "$list->{'name'}".'@'."$list->{'admin'}{'host'}"; 
 
238
    my $list_email = $list->get_list_address();
231
239
    my $dn = "cn=$list_email,$Conf{'ldap_export'}{$directory}{'suffix'}";
232
240
    my $filter = "(listEmailAddress = $list_email)";
233
241
    
273
281
        return undef;
274
282
    }
275
283
   
276
 
    $ldap->bind();
 
284
    my $cnx = $ldap->bind();
 
285
        
 
286
    unless(defined($cnx) && ($cnx->code == 0)){
 
287
        &Log::do_log('err', 'Ldap::exported_lists: Bind failed on  %s',$Conf{'ldap_export'}{$directory}{'host'});
 
288
        $ldap->unbind;
 
289
        return undef;
 
290
    }
277
291
        
278
292
    my $search_filter = "(|(listEmailAddress=*$filter*)(listSubject=*$filter*))";
279
293
    my $result_search = $ldap->search (
326
340
    }
327
341
 
328
342
    ##Bind
329
 
    $ldap->bind();
 
343
    my $cnx = $ldap->bind();
 
344
 
 
345
    unless(defined($cnx) && ($cnx->code == 0)){
 
346
        &Log::do_log('err', 'Ldap::exported_lists: Bind failed on  %s',$datas->{'host'});
 
347
        $ldap->unbind;
 
348
        return undef;
 
349
    }
 
350
    
330
351
 
331
352
    ##Search
332
353
    my $result_search = $ldap->search (