This file is indexed.

/usr/share/perl5/Net/LDAP/Extra/eDirectory.pm is in libnet-ldap-perl 1:0.6500+dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
package Net::LDAP::Extra::eDirectory;

use strict;

use Encode;
use Exporter qw(import);
use Convert::ASN1 qw(ASN_NULL);
use Net::LDAP::RootDSE;

require Net::LDAP::Extension;

our @ISA = qw(Net::LDAP::Extension);
our $VERSION = '0.03';

our @EXPORT = qw(is_eDirectory
                 list_replicas
                 get_replica_info
                 _trigger_proccess
                 trigger_backlinker
                 trigger_janitor
                 trigger_limber
                 trigger_skulker
                 trigger_schemasync
                 trigger_partitionpurge
                 refresh_ldap_server);


sub is_eDirectory {
  my $self = shift;
  my $rootdse = $self->root_dse()
    or return undef;

  return ($rootdse->supported_extension(qw(2.16.840.1.113719.1.27.100.9
                                           2.16.840.1.113719.1.27.100.19)))
         ? 1 : 0;
}

my $listReplicasReq = Convert::ASN1->new;
$listReplicasReq->prepare(q<serverDN OCTET STRING>);

my $listReplicasRes = Convert::ASN1->new;
$listReplicasRes->prepare(q<replicaList SEQUENCE OF OCTET STRING>);

sub list_replicas {
  my $ldap = shift;
  my $serverDN = shift;
  my %opt = @_;

  my $res = $ldap->extension(
        name => '2.16.840.1.113719.1.27.100.19',
        value => $listReplicasReq->encode(serverDN => $serverDN),
        ($opt{control} ? (control => $opt{control}) : ())
  );

  bless $res; # Naughty :-)
}

sub replicas {
  my $self = shift;
  my $out;

  if ($self->code == 0 && $self->response_name eq '2.16.840.1.113719.1.27.100.20') {
    $out = $listReplicasRes->decode($self->response);

    return wantarray ? @{$out->{replicaList}} : $out->{replicaList}
      if (ref($out) && exists($out->{replicaList}));
  }

  undef;
}


my $GetReplicaInfoReq = Convert::ASN1->new;
$GetReplicaInfoReq->prepare(q<serverDN     OCTET STRING,
                              partitionDN  OCTET STRING>);

my $GetReplicaInfoRes = Convert::ASN1->new;
$GetReplicaInfoRes->prepare(q<partitionID       INTEGER,
                              replicaState      INTEGER,
                              modificationTime  INTEGER,
                              purgeTime         INTEGER,
                              localPartitionID  INTEGER,
                              partitionDN       OCTET STRING,
                              replicaType       INTEGER,
                              flags             INTEGER>);

sub get_replica_info {
  my $ldap = shift;
  my $serverDN = shift;
  my $partitionDN = shift;
  my %opt = @_;

  my $res = $ldap->extension(
        name => '2.16.840.1.113719.1.27.100.17',
        value => $GetReplicaInfoReq->encode(serverDN    => $serverDN,
                                            partitionDN => $partitionDN),
        ($opt{control} ? (control => $opt{control}) : ())
  );

  bless $res; # Naughty :-)
}

sub replica_info {
  my $self = shift;

  if ($self->code == 0 && $self->response_name eq '2.16.840.1.113719.1.27.100.18') {
     my $out = $GetReplicaInfoRes->decode($self->response);

     return wantarray ? %{$out} : $out;
  }

  undef;
}

use constant {
  EDIR_BK_PROCESS_BKLINKER    => 1,
  EDIR_BK_PROCESS_JANITOR     => 2,
  EDIR_BK_PROCESS_LIMBER      => 3,
  EDIR_BK_PROCESS_SKULKER     => 4,
  EDIR_BK_PROCESS_SCHEMA_SYNC => 5,
  EDIR_BK_PROCESS_PART_PURGE  => 6
};

sub _trigger_proccess()
{
my $ldap = shift;
my $type = shift;
my %opt = @_;
my %typemap = ( 1 => '2.16.840.1.113719.1.27.100.43',
                2 => '2.16.840.1.113719.1.27.100.47',
                3 => '2.16.840.1.113719.1.27.100.49',
                4 => '2.16.840.1.113719.1.27.100.51',
                5 => '2.16.840.1.113719.1.27.100.53',
                6 => '2.16.840.1.113719.1.27.100.55',
		2.16.840.1.113719.1.27.100.9 => '2.16.840.1.113719.1.27.100.9' );

  $type = $typemap{$type}  if ($typemap{$type});

  return undef  if (!grep(/^\Q$type\E$/, values(%typemap)));

  my $res = $ldap->extension(
        name => $type,
        value => ASN_NULL,
        ($opt{control} ? (control => $opt{control}) : ())
  );

  bless $res; # Naughty :-)
}

sub trigger_backlinker {
  my $ldap = shift;
  $ldap->_trigger_proccess(EDIR_BK_PROCESS_BKLINKER, @_);
}

sub trigger_janitor {
  my $ldap = shift;
  $ldap->_trigger_proccess(EDIR_BK_PROCESS_JANITOR, @_);
}

sub trigger_limber {
  my $ldap = shift;
  $ldap->_trigger_proccess(EDIR_BK_PROCESS_LIMBER, @_);
}

sub trigger_skulker {
  my $ldap = shift;
  $ldap->_trigger_proccess(EDIR_BK_PROCESS_SKULKER, @_);
}

sub trigger_schemasync {
  my $ldap = shift;
  $ldap->_trigger_proccess(EDIR_BK_PROCESS_SCHEMA_SYNC, @_);
}

sub trigger_partitionpurge {
  my $ldap = shift;
  $ldap->_trigger_proccess(EDIR_BK_PROCESS_PART_PURGE, @_);
}

sub refresh_ldap_server {
  my $ldap = shift;
  $ldap->_trigger_proccess('2.16.840.1.113719.1.27.100.9', @_);
}

1;

__END__

=head1 NAME

Net::LDAP::Extra::eDirectory -- extensions for Novell eDirectory

=head1 SYNOPSIS

  use Net::LDAP::Extra qw(eDirectory);

  $ldap = Net::LDAP->new( ... );

  ...

  if ($ldap->is_eDirectory)
    my $mesg $ldap->list_replicas($server_dn);

    print "Replicas on $server_dn\n* " . join("\n* ", $mesg->replicas) . "\n"
      if (!$mesg->code);
  }

=head1 DESCRIPTION

Net::LDAP::Extra::eDirectory provides functions / LDAP extensions
specific to Novell eDirectory.

To do so, it provides the following methods:

=head1 METHODS

=over 4

=item is_eDirectory ( )

Tell if the LDAP server queried is Novell eDirectory server.

As the check is done by querying the root DSE of the directory,
it works without being bound to the directory.

In contrast to other Net::LDAP methods this method returns
TRUE / FALSE respectively undef on error.

=item list_replicas ( SERVER_DN, OPTIONS )

Query the replicas on the given server I<SERVER_DN>.

On success, the resulting Net::LDAP::Message object supports the method
C<replicas> that returns the list of replicas on I<SERVER_DN>.

=item get_replica_info ( SERVER_DN, REPLICA_DN, OPTIONS )

Query information of I<REPLICA_DN> on I<SERVER_DN>.

On success, the resulting Net::LDAP::Message object supports the method
C<replica_info> that returns a hash containing information on I<REPLICA_DN>.

=item trigger_backlinker ( OPTIONS )

Trigger the BackLinker process, which resolves external references
to ensure they refer to real entries.

=item trigger_janitor ( OPTIONS )

Trigger the Janitor process, which checks connectivity to all servers in database.

=item trigger_limber ( OPTIONS )

Trigger the Limber process, which verifies the server name,
internal ipx address and tree connectivity of all replicas.

=item trigger_skulker ( OPTIONS )

Trigger the Skulker process, which checks the synchronization status
of every server in the replica ring.

=item trigger_schemasync ( OPTIONS )

Trigger SchemaSync.

=item trigger_partitionpurge ( OPTIONS )

Trigger PartitionPurge.

=item refresh_ldap_server ( OPTIONS )

Trigger refreshing the NLDAP service.

=back

=head1 AUTHOR

Peter Marschall E<lt>peter@adpm.deE<gt>

=head1 COPYRIGHT

Copyright (c) 2013 Peter Marschall. All rights reserved. This program is
free software; you can redistribute it and/or modify it under the same
terms as Perl itself.