summaryrefslogtreecommitdiff
path: root/lib/Kolab/LDAP/Backend/ad.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Kolab/LDAP/Backend/ad.pm')
-rw-r--r--lib/Kolab/LDAP/Backend/ad.pm174
1 files changed, 87 insertions, 87 deletions
diff --git a/lib/Kolab/LDAP/Backend/ad.pm b/lib/Kolab/LDAP/Backend/ad.pm
index 668b67f..33f0789 100644
--- a/lib/Kolab/LDAP/Backend/ad.pm
+++ b/lib/Kolab/LDAP/Backend/ad.pm
@@ -48,7 +48,7 @@ our %EXPORT_TAGS = (
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw(
-
+
);
our $VERSION = '0.9';
@@ -80,35 +80,35 @@ sub changeCallback
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;
- }
+ 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);
+ 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;
+ 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;
+ 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;
+ 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::deleteObject($ldap, $cyrus, $entry);
+ return;
}
Kolab::LDAP::createObject($ldap, $cyrus, $entry);
@@ -123,8 +123,8 @@ sub run
$SIG{'TERM'} = \&shutdown;
END {
- alarm 0;
- Kolab::LDAP::destroy($ldap);
+ alarm 0;
+ Kolab::LDAP::destroy($ldap);
}
my $mesg;
@@ -136,81 +136,81 @@ sub run
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', '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
+ );
- Kolab::log('AD', 'Control created', KOLAB_DEBUG);
+ if (!$ldap) {
+ Kolab::log('AD', 'Sleeping 5 seconds...');
+ sleep 5;
+ next;
+ }
- my @userdns = split(/;/, $Kolab::config{'user_dn_list'});
- my $userdn;
+ Kolab::log('AD', 'LDAP connection established', KOLAB_DEBUG);
- Kolab::log('AD', 'User DN list = ' . $Kolab::config{'user_dn_list'}, KOLAB_DEBUG);
+ Kolab::LDAP::ensureAsync($ldap);
- if (length(@userdns) == 0) {
- Kolab::log('AD', 'No user DNs specified, exiting', KOLAB_ERROR);
- exit(1);
- }
+ Kolab::log('AD', 'Async checked', KOLAB_DEBUG);
- 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'},
- ],
+ my $ctrl = Net::LDAP::Control->new(
+ type => '1.2.840.113556.1.4.528',
+ critical => 'true'
);
- 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', '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;
};
-
- 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;
- };
- }
+ } # End of while
1;
}