bo: server/perl-kolab/Kolab-LDAP-Backend-ad Changes, NONE, 1.1 MANIFEST, NONE, 1.1 META.yml, NONE, 1.1 Makefile.PL, NONE, 1.1 README, NONE, 1.1 ad.pm, NONE, 1.1
cvs at intevation.de
cvs at intevation.de
Wed Mar 31 17:36:50 CEST 2004
Author: bo
Update of /kolabrepository/server/perl-kolab/Kolab-LDAP-Backend-ad
In directory doto:/tmp/cvs-serv3870/perl-kolab/Kolab-LDAP-Backend-ad
Added Files:
Changes MANIFEST META.yml Makefile.PL README ad.pm
Log Message:
perl-kolab packages imported
--- NEW FILE: Changes ---
Revision history for Perl extension Kolab::LDAP::Backend::ad.
0.01 Thu Nov 6 14:05:59 2003
- original version; created by h2xs 1.22 with options
-XA -n Kolab::LDAP::Backend::ad
--- NEW FILE: MANIFEST ---
ad.pm
Changes
Makefile.PL
MANIFEST
README
t/1.t
META.yml Module meta-data (added by MakeMaker)
--- NEW FILE: META.yml ---
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Kolab-LDAP-Backend-ad
version: 0.9
version_from: ad.pm
installdirs: site
requires:
distribution_type: module
generated_by: ExtUtils::MakeMaker version 6.17
--- NEW FILE: Makefile.PL ---
use 5.008;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
'NAME' => 'Kolab::LDAP::Backend::ad',
'VERSION_FROM' => 'ad.pm', # finds $VERSION
'PREREQ_PM' => {}, # e.g., Module::Name => 1.1
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'ad.pm', # retrieve abstract from module
AUTHOR => 'root <root@(none)>') : ()),
);
--- NEW FILE: README ---
Kolab/LDAP/Backend/ad version 0.9
==================================
The README is used to introduce the module and provide instructions on
how to install the module, any machine dependencies it may have (for
example C compilers and installed libraries) and any other information
that should be provided before the module is installed.
A README file is required for CPAN modules since CPAN extracts the
README file from a module distribution so that people browsing the
archive can use it get an idea of the modules uses. It is usually a
good idea to provide version information here so that people can
decide whether fixes for the module are worth downloading.
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
make test
make install
COPYRIGHT AND LICENCE
Copyright (c) 2003 Code Fusion cc
Writen by Stuart Bingë <s.binge at codefusion.co.za>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You can view the GNU General Public License, online, at the GNU
Project's homepage; see <http://www.gnu.org/licenses/gpl.html>.
--- NEW FILE: ad.pm ---
package Kolab::LDAP::Backend::ad;
##
## Copyright (c) 2003 Code Fusion cc
##
## Writen by Stuart Bingë <s.binge at codefusion.co.za>
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You can view the GNU General Public License, online, at the GNU
## Project's homepage; see <http://www.gnu.org/licenses/gpl.html>.
##
use 5.008;
use strict;
use warnings;
use Kolab;
use Kolab::Util;
use Kolab::LDAP;
use Net::LDAP;
use Net::LDAP::Control;
use vars qw($ldap $cyrus);
require Exporter;
our @ISA = qw(Exporter);
our %EXPORT_TAGS = (
'all' => [ qw(
&startup
&run
) ]
);
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw(
);
our $VERSION = '0.9';
sub startup { 1; }
sub shutdown
{
Kolab::log('AD', 'Shutting down');
exit(0);
}
sub abort
{
Kolab::log('AD', 'Aborting');
exit(1);
}
sub changeCallback
{
Kolab::log('AD', 'Change notification received', KOLAB_DEBUG);
### $_[0] isa Net::LDAP::Message
### $_[1] shouldbea Net::LDAP::Entry
my $mesg = shift || 0;
my $entry = shift || 0;
my $issearch = $mesg->isa("Net::LDAP::Search");
if (!$issearch) {
Kolab::log('AD', 'mesg is not a search object, testing code...', KOLAB_DEBUG);
if ($mesg->code == 88) {
Kolab::log('AD', 'changeCallback() -> Exit code received, returning', KOLAB_DEBUG);
return;
} elsif ($mesg->code) {
Kolab::log('AD', "mesg->code = `" . $mesg->code . "', mesg->msg = `" . $mesg->error . "'", KOLAB_DEBUG);
&abort;
}
} else {
Kolab::log('AD', 'mesg is a search object, not testing code', KOLAB_DEBUG);
}
if (!$entry) {
Kolab::log('AD', 'changeCallback() called with a null entry', KOLAB_DEBUG);
return;
} elsif (!$entry->isa("Net::LDAP::Entry")) {
Kolab::log('AD', 'changeCallback() called with an invalid entry', KOLAB_DEBUG);
return;
}
if (!Kolab::LDAP::isObject($entry, $Kolab::config{'user_object_class'})) {
Kolab::log('AD', "Entry is not a `" . $Kolab::config{'user_object_class'} . "', returning", KOLAB_DEBUG);
return;
}
my $deleted = $entry->get_value($Kolab::config{'user_field_deleted'}) || 0;
if ($deleted) {
Kolab::LDAP::deleteObject($ldap, $cyrus, $entry);
return;
}
Kolab::LDAP::createObject($ldap, $cyrus, $entry);
}
sub run
{
# This should be called from a separate thread, as we set our
# own interrupt handlers here
$SIG{'INT'} = \&shutdown;
$SIG{'TERM'} = \&shutdown;
END {
alarm 0;
Kolab::LDAP::destroy($ldap);
}
my $mesg;
Kolab::log('AD', 'Listener starting up');
$cyrus = Kolab::Cyrus::create;
Kolab::log('AD', 'Cyrus connection established', KOLAB_DEBUG);
while (1) {
Kolab::log('AD', 'Creating LDAP connection to AD server', KOLAB_DEBUG);
$ldap = Kolab::LDAP::create(
$Kolab::config{'user_ldap_ip'},
$Kolab::config{'user_ldap_port'},
$Kolab::config{'user_bind_dn'},
$Kolab::config{'user_bind_pw'},
1
);
if (!$ldap) {
Kolab::log('AD', 'Sleeping 5 seconds...');
sleep 5;
next;
}
Kolab::log('AD', 'LDAP connection established', KOLAB_DEBUG);
Kolab::LDAP::ensureAsync($ldap);
Kolab::log('AD', 'Async checked', KOLAB_DEBUG);
my $ctrl = Net::LDAP::Control->new(
type => '1.2.840.113556.1.4.528',
critical => 'true'
);
Kolab::log('AD', 'Control created', KOLAB_DEBUG);
my @userdns = split(/;/, $Kolab::config{'user_dn_list'});
my $userdn;
Kolab::log('AD', 'User DN list = ' . $Kolab::config{'user_dn_list'}, KOLAB_DEBUG);
if (length(@userdns) == 0) {
Kolab::log('AD', 'No user DNs specified, exiting', KOLAB_ERROR);
exit(1);
}
foreach $userdn (@userdns) {
Kolab::log('AD', "Registering change notification on DN `$userdn'");
$mesg = $ldap->search (
base => $userdn,
scope => 'one',
control => [ $ctrl ],
callback => \&changeCallback,
filter => '(objectClass=*)',
attrs => [
'*',
$Kolab::config{'user_field_guid'},
$Kolab::config{'user_field_modified'},
$Kolab::config{'user_field_quota'},
$Kolab::config{'user_field_deleted'},
],
);
Kolab::log('AD', "Change notification registered on `$userdn'");
}
eval {
local $SIG{ALRM} = sub {
alarm 0;
Kolab::log('AD', 'Connection refresh period expired; tearing down connection');
Kolab::LDAP::destroy($ldap);
next;
};
Kolab::log('AD', 'Waiting for changes (refresh period = ' . $Kolab::config{'conn_refresh_period'} . ' minutes)...');
alarm $Kolab::config{'conn_refresh_period'} * 60;
$mesg->sync;
alarm 0;
};
}
1;
}
1;
__END__
# Below is stub documentation for your module. You'd better edit it!
=head1 NAME
Kolab::LDAP::Backend::ad - Perl extension for an Active Directory backend
=head1 ABSTRACT
Kolab::LDAP::Backend::ad handles an Active Directory backend to the
kolab daemon.
=head1 AUTHOR
Stuart Bingë, E<lt>s.binge at codefusion.co.zaE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (c) 2003 Code Fusion cc
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You can view the GNU General Public License, online, at the GNU
Project's homepage; see <http://www.gnu.org/licenses/gpl.html>.
=cut
More information about the commits
mailing list