add_forward implemented
del_forward implemented update_vacation implemented update_filter improved (support multiple ldap entries)
This commit is contained in:
parent
b95baa8ca0
commit
56be2f41f5
6 changed files with 359 additions and 51 deletions
|
@ -25,21 +25,14 @@ Lang {
|
||||||
Buttons {
|
Buttons {
|
||||||
Password = Passwort aendern
|
Password = Passwort aendern
|
||||||
AddForward = Weiterleitung hinzufuegen
|
AddForward = Weiterleitung hinzufuegen
|
||||||
DelForward = Weiterleitung entfernen
|
DelForward = Weiterleitung(en) entfernen
|
||||||
Filter = Einstellung speichern
|
Filter = Einstellung speichern
|
||||||
Vacation = Einstellung speichern
|
Vacation = Einstellung speichern
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Options {
|
|
||||||
filter_on = Aktiviere den Spam-Filter
|
|
||||||
spam_move = Verschiebe Spam in ein eigenes Verzeichnis
|
|
||||||
vacation_on = Aktivieren Abwesenheits-Benachrichtigung
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Misc {
|
Misc {
|
||||||
NewForwardAddress = Neue Weiterleitungsadresse
|
NewForward = Neue Weiterleitungsadresse
|
||||||
VacationText = Benachrichtigungstext
|
VacationText = Benachrichtigungstext
|
||||||
Password = Mailaccount-Passwort
|
Password = Mailaccount-Passwort
|
||||||
OldPassword = Altes Passwort
|
OldPassword = Altes Passwort
|
||||||
|
@ -52,6 +45,12 @@ Lang {
|
||||||
StatusSpamNone = eingehende Nachrichten werden nicht auf Spam geprueft
|
StatusSpamNone = eingehende Nachrichten werden nicht auf Spam geprueft
|
||||||
StatusSpamMark = Spam wird markiert
|
StatusSpamMark = Spam wird markiert
|
||||||
StatusSpamMove = Spam wird in das Spam-Verzeichnis verschoben
|
StatusSpamMove = Spam wird in das Spam-Verzeichnis verschoben
|
||||||
|
Vacation = Abwesenheitsbenachrichtigung versenden
|
||||||
|
VacationText = Inhalt der automatischen Abwesenheitsnachricht
|
||||||
|
ForwardCount = Anzahl der Mail-Weiterleitungen
|
||||||
|
NoForward = Keine Weiterleitungen
|
||||||
|
VacationEnabled = Abwesenheitsnachrichten werden versandt
|
||||||
|
VacationDisabled = Keine Abwesenhitsnachrichten
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorMessage {
|
ErrorMessage {
|
||||||
|
@ -61,8 +60,18 @@ Lang {
|
||||||
|
|
||||||
|
|
||||||
WarningMessage {
|
WarningMessage {
|
||||||
FilterConnfig = Die Filterungseinstellungen konnten nicht gespeichert werden!
|
LdapConnect = Fehler beim Zugriff auf den LDAP-Server!
|
||||||
|
FilterConfig = Die Filterungseinstellungen konnten nicht gespeichert werden!
|
||||||
|
AddForward = Die Weiterleitung konnte nicht aktiviert werden!
|
||||||
|
DelForward = Mindestens eine Weiterleitung konnte nicht entfernt werden!
|
||||||
|
ExistingForward = Diese Weiterleitung existiert bereits!
|
||||||
WrongPassword = Das angegebene Passwort war nicht korrekt!
|
WrongPassword = Das angegebene Passwort war nicht korrekt!
|
||||||
|
InvalidAddress = Die angegebene Mailadresse ist ungueltig!
|
||||||
|
EmptyAddress = Es wurde keine Mailadresse angegeben!
|
||||||
|
ForwardNotFound = Die Weiterleitung war nicht vorhanden!
|
||||||
|
EmptyVacationText = Der Abwesenheitstext darf nicht leer sein!
|
||||||
|
ToggleVacation = Das Aendern des Abwesenheitsmodus schlug fehl!
|
||||||
|
SetVacationText = Das Speichern der Abwesenheitsnachricht schlug fehl!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,7 +93,8 @@ Lang {
|
||||||
StatusForward = Weiterleitungen
|
StatusForward = Weiterleitungen
|
||||||
StatusVacation = Abwesenheitsbenachrichtigungen
|
StatusVacation = Abwesenheitsbenachrichtigungen
|
||||||
Password = Passwort aendern
|
Password = Passwort aendern
|
||||||
Forward = Weiterleitungen verwalten
|
DelForward = Weiterleitung(en) entfernen
|
||||||
|
AddForward = Weiterleitungen hinzufuegen
|
||||||
Filter = Spam-Filterung einrichten
|
Filter = Spam-Filterung einrichten
|
||||||
Vacation = Abwesenheitsbenachrichtigung einrichten
|
Vacation = Abwesenheitsbenachrichtigung einrichten
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,13 @@ $LDAP_HOST = 'ldap.sao';
|
||||||
# the string '_USERNAME_' will be replaced by the real username
|
# the string '_USERNAME_' will be replaced by the real username
|
||||||
$LDAP_USER_DN = "cn=_USERNAME_,sc=mailAccount,ou=People,o=neofaxe,dc=systemausfall,dc=org";
|
$LDAP_USER_DN = "cn=_USERNAME_,sc=mailAccount,ou=People,o=neofaxe,dc=systemausfall,dc=org";
|
||||||
|
|
||||||
$LDAP_SPAM_MOVE = "/usr/local/bin/ifspamh spam-_USERNAME_\@systemausfall.org";
|
#$LDAP_SPAM_MOVE = "/usr/local/bin/ifspamh spam-_USERNAME_\@systemausfall.org";
|
||||||
$LDAP_SPAM_MARK = "/usr/local/bin/ifspamh spam-_USERNAME_\@systemausfall.org || /bin/true";
|
|
||||||
|
# spam filtering disables forwarding and local delivery (for spam)
|
||||||
|
# dot-qmail files will be used, if there
|
||||||
|
$LDAP_SPAM_MOVE = [ "deliveryProgramPath" => "/data/scripts/spam_moving.sh" ];
|
||||||
|
|
||||||
|
# for tagging spam, you need to turn off local delivery (no dot-qmail files, no maildir)
|
||||||
|
$LDAP_SPAM_MARK = [ "deliveryProgramPath" => "/data/scripts/spam_tagging.sh",
|
||||||
|
"deliveryMode" => "nolocal" ];
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,9 @@ use CGI;
|
||||||
use IO::File;
|
use IO::File;
|
||||||
use Net::LDAP;
|
use Net::LDAP;
|
||||||
|
|
||||||
|
# Net::LDAP will care about base64 encoding for multiline ldap entries
|
||||||
|
#use MIME::Base64;
|
||||||
|
|
||||||
my $q = new CGI;
|
my $q = new CGI;
|
||||||
$q->import_names('Q');
|
$q->import_names('Q');
|
||||||
|
|
||||||
|
@ -77,7 +80,7 @@ if ($action eq '' || $action eq 'overview') {
|
||||||
$pagename = 'forward_form';
|
$pagename = 'forward_form';
|
||||||
} elsif ($action eq 'forward_add') {
|
} elsif ($action eq 'forward_add') {
|
||||||
# add a forwarding address
|
# add a forwarding address
|
||||||
if (defined($q->param('options_forward_add_address'))) {
|
if (defined($q->param('fw_address'))) {
|
||||||
$success = 'AddForward' if (&add_forward());
|
$success = 'AddForward' if (&add_forward());
|
||||||
$pagename = 'forward_form';
|
$pagename = 'forward_form';
|
||||||
} else {
|
} else {
|
||||||
|
@ -87,7 +90,7 @@ if ($action eq '' || $action eq 'overview') {
|
||||||
} elsif ($action eq 'forward_del') {
|
} elsif ($action eq 'forward_del') {
|
||||||
# remove a forwarding address
|
# remove a forwarding address
|
||||||
# no selected address -> no error
|
# no selected address -> no error
|
||||||
if (defined($q->param('options_forward_del_address'))) {
|
if (defined($q->param('fw_delete'))) {
|
||||||
$success = 'DelForward' if (&del_forward());
|
$success = 'DelForward' if (&del_forward());
|
||||||
$pagename = 'forward_form';
|
$pagename = 'forward_form';
|
||||||
} else {
|
} else {
|
||||||
|
@ -125,45 +128,201 @@ sub set_pagedata {
|
||||||
$pagedata->setValue('Data.isSpamMove', &is_spam_move()? 1 : 0);
|
$pagedata->setValue('Data.isSpamMove', &is_spam_move()? 1 : 0);
|
||||||
$pagedata->setValue('Data.isSpamMark', &is_spam_mark()? 1 : 0);
|
$pagedata->setValue('Data.isSpamMark', &is_spam_mark()? 1 : 0);
|
||||||
$pagedata->setValue('Data.UserName', $mail_user);
|
$pagedata->setValue('Data.UserName', $mail_user);
|
||||||
|
|
||||||
|
# retrieve frowarding addresses
|
||||||
|
my $one_forward;
|
||||||
|
my $i = 0;
|
||||||
|
foreach $one_forward (&get_ldap_values('mailForwardingAddress')) {
|
||||||
|
$pagedata->setValue("Data.ForwardAddresses.$i", $one_forward);
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $vacation_text = &get_ldap_values('mailReplyText');
|
||||||
|
# encoding is not necessary -> automatically done by Net::LDAP
|
||||||
|
#$vacation_text = MIME::Base64::decode_base64($vacation_text);
|
||||||
|
my $vacation_state = &compare_ldap_attr('deliveryMode', 'reply');
|
||||||
|
$pagedata->setValue('Data.VacationText', $vacation_text);
|
||||||
|
$pagedata->setValue('Data.isVacation', $vacation_state? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
sub update_filter {
|
sub add_forward {
|
||||||
|
|
||||||
my $ldif;
|
|
||||||
my $password = $q->param('pw');
|
|
||||||
my $result;
|
|
||||||
my $ldap;
|
|
||||||
my $user_dn = $LDAP_USER_DN;
|
my $user_dn = $LDAP_USER_DN;
|
||||||
$user_dn =~ s/_USERNAME_/$mail_user/g;
|
$user_dn =~ s/_USERNAME_/$mail_user/g;
|
||||||
|
my $password = $q->param('pw');
|
||||||
|
my $new_forward = $q->param('fw_address');
|
||||||
|
|
||||||
$ldap = Net::LDAP->new($LDAP_HOST);
|
if ($new_forward eq '') {
|
||||||
$result = $ldap->bind($user_dn, password => $password);
|
$warning = 'EmptyAddress';
|
||||||
|
return (0==1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$new_forward =~ /^([\w\_\-\.]*\@[\w\_\-\.]*)/;
|
||||||
|
$new_forward = $1;
|
||||||
|
|
||||||
|
if ($new_forward eq '') {
|
||||||
|
$warning = 'InvalidAddress';
|
||||||
|
return (0==1);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $ldap = Net::LDAP->new($LDAP_HOST);
|
||||||
|
my $result = $ldap->bind($user_dn, password => $password);
|
||||||
if ($result->is_error) {
|
if ($result->is_error) {
|
||||||
$warning = 'WrongPassword';
|
$warning = 'WrongPassword';
|
||||||
return (0==1);
|
return (0==1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($q->param('filter_type') eq 'none') {
|
if (&compare_ldap_attr('mailForwardingAddress', $new_forward)) {
|
||||||
if (&is_spam_mark() || &is_spam_move()) {
|
$warning = 'ExistingForward';
|
||||||
$result = $ldap->modify($user_dn, delete => ['deliveryProgramPath']);
|
$ldap->unbind;
|
||||||
|
return (0==1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $ldap->modify($user_dn, add => { mailForwardingAddress => $new_forward });
|
||||||
|
$ldap->unbind;
|
||||||
|
|
||||||
|
if ($result->is_error) {
|
||||||
|
$warning = 'AddForward';
|
||||||
|
return (0==1);
|
||||||
|
} else {
|
||||||
|
return (0==0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
sub del_forward {
|
||||||
|
my $user_dn = $LDAP_USER_DN;
|
||||||
|
$user_dn =~ s/_USERNAME_/$mail_user/g;
|
||||||
|
my $password = $q->param('pw');
|
||||||
|
if ($q->param('fw_delete') eq '') {
|
||||||
|
$warning = 'EmptyAddress';
|
||||||
|
return (0==1);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $ldap = Net::LDAP->new($LDAP_HOST);
|
||||||
|
my $result = $ldap->bind($user_dn, password => $password);
|
||||||
|
if ($result->is_error) {
|
||||||
|
$warning = 'WrongPassword';
|
||||||
|
return (0==1);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $address;
|
||||||
|
my $successes = 0;
|
||||||
|
foreach $address ($q->param('fw_delete')) {
|
||||||
|
$address =~ /^([\w\_\-\.]*\@[\w\_\-\.]*)/;
|
||||||
|
$address = $1;
|
||||||
|
if ($address eq '') {
|
||||||
|
$warning = 'InvalidAddress' unless ($warning);
|
||||||
|
} else {
|
||||||
|
if (&compare_ldap_attr('mailForwardingAddress', $address)) {
|
||||||
|
$result = $ldap->modify($user_dn,
|
||||||
|
delete => { mailForwardingAddress => $address });
|
||||||
|
if ($result->is_error) {
|
||||||
|
$warning = 'DelForward';
|
||||||
|
} else {
|
||||||
|
$successes++;
|
||||||
|
}
|
||||||
|
return (0==1);
|
||||||
|
} else {
|
||||||
|
$warning = 'ForwardNotFound';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$ldap->unbind;
|
||||||
|
return ($successes > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
sub update_vacation {
|
||||||
|
my $failure = 0;
|
||||||
|
my $user_dn = $LDAP_USER_DN;
|
||||||
|
$user_dn =~ s/_USERNAME_/$mail_user/g;
|
||||||
|
my $password = $q->param('pw');
|
||||||
|
if (defined($q->param('vacation_enabled')) && ($q->param('vacation_text') eq '')) {
|
||||||
|
$warning = 'EmptyVacationText';
|
||||||
|
return (0==1);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $ldap = Net::LDAP->new($LDAP_HOST);
|
||||||
|
my $result = $ldap->bind($user_dn, password => $password);
|
||||||
|
if ($result->is_error) {
|
||||||
|
$warning = 'WrongPassword';
|
||||||
|
return (0==1);
|
||||||
|
}
|
||||||
|
|
||||||
|
# set vacation state
|
||||||
|
$result = undef;
|
||||||
|
if (defined($q->param('vacation_enabled'))) {
|
||||||
|
$result = $ldap->modify($user_dn, add => [ deliveryMode => 'reply' ])
|
||||||
|
unless (&compare_ldap_attr("deliveryMode", "reply"));
|
||||||
|
} else {
|
||||||
|
$result = $ldap->modify($user_dn, delete => { deliveryMode => 'reply' })
|
||||||
|
if (&compare_ldap_attr("deliveryMode", "reply"));
|
||||||
|
}
|
||||||
|
if (defined($result) && ($result->is_error)) {
|
||||||
|
$warning = 'ToggleVacation';
|
||||||
|
warn $result->error_text;
|
||||||
|
$failure = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
# set vacation text
|
||||||
|
$result = undef;
|
||||||
|
# a multiline vacation text has to be base64 encoded
|
||||||
|
# we encode it without a trailing line feed
|
||||||
|
my $vacation_text = $q->param('vacation_text');
|
||||||
|
# encoding is not necessary -> automatically done by Net::LDAP
|
||||||
|
#$vacation_text = MIME::Base64::encode_base64($vacation_text);
|
||||||
|
$ldap->modify($user_dn, delete => [ 'mailReplyText' ]); # may return an error
|
||||||
|
$result = $ldap->modify($user_dn, add => [ mailReplyText => $vacation_text ])
|
||||||
|
unless ($vacation_text eq '');
|
||||||
|
if (defined($result) && ($result->is_error)) {
|
||||||
|
$warning = 'SetVacationText';
|
||||||
|
$failure = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ldap->unbind;
|
||||||
|
return ($failure == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
sub update_filter {
|
||||||
|
my $ldif_move;
|
||||||
|
my $ldif_mark;
|
||||||
|
my $password = $q->param('pw');
|
||||||
|
my $user_dn = $LDAP_USER_DN;
|
||||||
|
$user_dn =~ s/_USERNAME_/$mail_user/g;
|
||||||
|
|
||||||
|
my $ldap = Net::LDAP->new($LDAP_HOST);
|
||||||
|
my $result = $ldap->bind($user_dn, password => $password);
|
||||||
|
if ($result->is_error) {
|
||||||
|
$warning = 'WrongPassword';
|
||||||
|
return (0==1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$ldif_move = &substitute_username($LDAP_SPAM_MOVE);
|
||||||
|
$ldif_mark = &substitute_username($LDAP_SPAM_MARK);
|
||||||
|
|
||||||
|
if ($q->param('filter_type') eq 'none') {
|
||||||
|
$result = $ldap->modify($user_dn, delete => { @$ldif_move })
|
||||||
|
if (&is_spam_move());
|
||||||
|
$result = $ldap->modify($user_dn, delete => { @$ldif_mark })
|
||||||
|
if (&is_spam_mark());
|
||||||
} elsif ($q->param('filter_type') eq 'move') {
|
} elsif ($q->param('filter_type') eq 'move') {
|
||||||
if (!&is_spam_move()) {
|
if (!&is_spam_move()) {
|
||||||
$ldif = $LDAP_SPAM_MOVE;
|
$ldap->modify($user_dn, delete => { @$ldif_mark })
|
||||||
$ldif =~ s/_USERNAME_/$mail_user/g;
|
|
||||||
$ldap->modify($user_dn, delete => [ 'deliveryProgramPath' ])
|
|
||||||
if (&is_spam_mark());
|
if (&is_spam_mark());
|
||||||
$result = $ldap->modify($user_dn, add => { deliveryProgramPath => $ldif });
|
$result = $ldap->modify($user_dn, add => $ldif_move);
|
||||||
}
|
}
|
||||||
} elsif ($q->param('filter_type') eq 'mark') {
|
} elsif ($q->param('filter_type') eq 'mark') {
|
||||||
if (!&is_spam_mark()) {
|
if (!&is_spam_mark()) {
|
||||||
$ldif = $LDAP_SPAM_MARK;
|
$ldap->modify($user_dn, delete => { @$ldif_move })
|
||||||
$ldif =~ s/_USERNAME_/$mail_user/g;
|
|
||||||
$ldap->modify($user_dn, delete => [ 'deliveryProgramPath' ])
|
|
||||||
if (&is_spam_move());
|
if (&is_spam_move());
|
||||||
$result = $ldap->modify($user_dn, add => { deliveryProgramPath => $ldif });
|
$result = $ldap->modify($user_dn, add => $ldif_mark);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$error = 'ParameterMissing';
|
$error = 'ParameterMissing';
|
||||||
|
@ -173,6 +332,7 @@ sub update_filter {
|
||||||
|
|
||||||
if ($result->is_error) {
|
if ($result->is_error) {
|
||||||
$warning = 'FilterConfig';
|
$warning = 'FilterConfig';
|
||||||
|
warn $result->error_text;
|
||||||
return (0==1);
|
return (0==1);
|
||||||
} else {
|
} else {
|
||||||
return (0==0);
|
return (0==0);
|
||||||
|
@ -181,18 +341,71 @@ sub update_filter {
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
sub update_password {
|
||||||
|
# TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
sub substitute_username {
|
||||||
|
my ($input) = @_;
|
||||||
|
my $value;
|
||||||
|
my @array;
|
||||||
|
my $count = 0;
|
||||||
|
foreach $value (@$input) {
|
||||||
|
# substitute only values - not keys
|
||||||
|
if ($count == 0) {
|
||||||
|
$count++;
|
||||||
|
} else {
|
||||||
|
$value =~ s/_USERNAME_/$mail_user/g;
|
||||||
|
$count = 0;
|
||||||
|
}
|
||||||
|
push @array, $value;
|
||||||
|
}
|
||||||
|
return \@array;
|
||||||
|
}
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
sub is_spam_move {
|
sub is_spam_move {
|
||||||
return &compare_ldap_attr('deliveryProgramPath', $LDAP_SPAM_MOVE);
|
my $key;
|
||||||
|
my $value;
|
||||||
|
my $count = 0;
|
||||||
|
my $failed = 0;
|
||||||
|
foreach $value (@$LDAP_SPAM_MOVE) {
|
||||||
|
if ($count == 0) {
|
||||||
|
$key = $value;
|
||||||
|
$count++;
|
||||||
|
} else {
|
||||||
|
$failed++ unless &compare_ldap_attr($key, $value);
|
||||||
|
$count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ($failed == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
sub is_spam_mark {
|
sub is_spam_mark {
|
||||||
return &compare_ldap_attr('deliveryProgramPath', $LDAP_SPAM_MARK);
|
my $key;
|
||||||
|
my $value;
|
||||||
|
my $count = 0;
|
||||||
|
my $failed = 0;
|
||||||
|
foreach $value (@$LDAP_SPAM_MARK) {
|
||||||
|
if ($count == 0) {
|
||||||
|
$key = $value;
|
||||||
|
$count++;
|
||||||
|
} else {
|
||||||
|
$failed++ unless &compare_ldap_attr($key, $value);
|
||||||
|
$count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ($failed == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# values will get substituted (e.g. _USERNAME_ ...)
|
||||||
sub compare_ldap_attr {
|
sub compare_ldap_attr {
|
||||||
my ($attr, $value) = @_;
|
my ($attr, $value) = @_;
|
||||||
my $ldap = Net::LDAP->new($LDAP_HOST);
|
my $ldap = Net::LDAP->new($LDAP_HOST);
|
||||||
|
@ -203,7 +416,11 @@ sub compare_ldap_attr {
|
||||||
|
|
||||||
$value =~ s/_USERNAME_/$mail_user/g;
|
$value =~ s/_USERNAME_/$mail_user/g;
|
||||||
|
|
||||||
$ldap->bind;
|
$result = $ldap->bind;
|
||||||
|
if ($result->is_error) {
|
||||||
|
$warning = 'LdapConnect' unless ($warning);
|
||||||
|
return (0==1);
|
||||||
|
}
|
||||||
$result = $ldap->compare($user_dn,
|
$result = $ldap->compare($user_dn,
|
||||||
attr => $attr,
|
attr => $attr,
|
||||||
value => $value);
|
value => $value);
|
||||||
|
@ -213,6 +430,40 @@ sub compare_ldap_attr {
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
sub get_ldap_values {
|
||||||
|
my $attr = shift;
|
||||||
|
my $user_dn = $LDAP_USER_DN;
|
||||||
|
$user_dn =~ s/_USERNAME_/$mail_user/g;
|
||||||
|
|
||||||
|
my $ldap = Net::LDAP->new($LDAP_HOST);
|
||||||
|
my $result = $ldap->bind;
|
||||||
|
if ($result->is_error) {
|
||||||
|
$warning = 'LdapConnect' if ($warning eq '');
|
||||||
|
return (0==1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $ldap->search( base => $user_dn,
|
||||||
|
scope => 'base',
|
||||||
|
filter => "($attr=*)",
|
||||||
|
attrs => [$attr]);
|
||||||
|
my $entry;
|
||||||
|
my @values;
|
||||||
|
# there will be only one entry
|
||||||
|
foreach $entry ($result->entries) {
|
||||||
|
@values = $entry->get_value($attr);
|
||||||
|
}
|
||||||
|
|
||||||
|
$ldap->unbind;
|
||||||
|
|
||||||
|
if (wantarray) {
|
||||||
|
return @values;
|
||||||
|
} else {
|
||||||
|
return $values[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
sub load_hdf {
|
sub load_hdf {
|
||||||
# initialize the data for clearsilver
|
# initialize the data for clearsilver
|
||||||
my $hdf = ClearSilver::HDF->new();
|
my $hdf = ClearSilver::HDF->new();
|
||||||
|
|
|
@ -2,20 +2,42 @@
|
||||||
<h1><?cs var:html_escape(Lang.Title.Forward) ?></h1>
|
<h1><?cs var:html_escape(Lang.Title.Forward) ?></h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?cs if:subcount(Data.ForwardAddresses) > 0 ?>
|
||||||
<fieldset class="form">
|
<fieldset class="form">
|
||||||
<legend><?cs var:html_escape(Lang.Legend.Forward) ?> </legend>
|
<legend><?cs var:html_escape(Lang.Legend.DelForward) ?> </legend>
|
||||||
|
|
||||||
<form method="post" action="<?cs var:Config.ScriptName ?>" enctype="application/x-www-form-urlencoded">
|
<form method="post" action="<?cs var:Config.ScriptName ?>" enctype="application/x-www-form-urlencoded">
|
||||||
<ul>
|
<ul>
|
||||||
<li>noch nicht implementiert</li>
|
<li><select name="fw_delete" multiple="multiple">
|
||||||
<!--
|
<?cs each:forward = Data.ForwardAddresses ?>
|
||||||
<li><label for="oldpw"><?cs var:html_escape(Lang.Misc.OldPassword) ?>:</label>
|
<option><?cs var:forward ?></option>
|
||||||
<input type="password" name="oldpassword" id="oldpw" size="20"></li>
|
<?cs /each ?></li>
|
||||||
-->
|
<li><label for="delpw"><?cs var:html_escape(Lang.Misc.Password) ?>:</label>
|
||||||
|
<input type="password" name="pw" id="delpw" size="20" /></li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<input type="hidden" name="action" value="forward_update" />
|
<input type="hidden" name="action" value="forward_del" />
|
||||||
|
<button type="submit" name="send" value="do"><?cs var:html_escape(Lang.Buttons.DelForward) ?></button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</fieldset>
|
||||||
|
<?cs /if ?>
|
||||||
|
|
||||||
|
<fieldset class="form">
|
||||||
|
<legend><?cs var:html_escape(Lang.Legend.AddForward) ?> </legend>
|
||||||
|
|
||||||
|
<form method="post" action="<?cs var:Config.ScriptName ?>" enctype="application/x-www-form-urlencoded">
|
||||||
|
<ul>
|
||||||
|
<li><label for="forward_add"><?cs var:html_escape(Lang.Misc.NewForward)
|
||||||
|
?>:</label>
|
||||||
|
<input type="text" id="forward_add" size="40" name="fw_address"/></li>
|
||||||
|
<li><label for="fwpw"><?cs var:html_escape(Lang.Misc.Password) ?>:</label>
|
||||||
|
<input type="password" name="pw" id="fwpw" size="20" /></li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<input type="hidden" name="action" value="forward_add" />
|
||||||
<button type="submit" name="send" value="do"><?cs var:html_escape(Lang.Buttons.AddForward) ?></button>
|
<button type="submit" name="send" value="do"><?cs var:html_escape(Lang.Buttons.AddForward) ?></button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,13 @@
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend><?cs var:html_escape(Lang.Legend.StatusForward) ?> </legend>
|
<legend><?cs var:html_escape(Lang.Legend.StatusForward) ?> </legend>
|
||||||
<p>noch nicht implementiert</p>
|
<p>
|
||||||
|
<?cs if:subcount(Data.ForwardAddresses) > 0 ?>
|
||||||
|
<?cs var:Lang.Misc.ForwardCount ?>: <?cs var:subcount(Data.ForwardAddresses) ?>
|
||||||
|
<?cs else ?>
|
||||||
|
<?cs var:Lang.Misc.NoForward ?>
|
||||||
|
<?cs /if ?>
|
||||||
|
</p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
@ -17,5 +23,11 @@
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend><?cs var:html_escape(Lang.Legend.StatusVacation) ?> </legend>
|
<legend><?cs var:html_escape(Lang.Legend.StatusVacation) ?> </legend>
|
||||||
<p>noch nicht implementiert</p>
|
<p>
|
||||||
|
<?cs if:Data.isVacation ?>
|
||||||
|
<?cs var:Lang.Misc.VacationEnabled ?>
|
||||||
|
<?cs else ?>
|
||||||
|
<?cs var:Lang.Misc.VacationDisabled ?>
|
||||||
|
<?cs /if ?>
|
||||||
|
</p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
|
@ -7,11 +7,17 @@
|
||||||
|
|
||||||
<form method="post" action="<?cs var:Config.ScriptName ?>" enctype="application/x-www-form-urlencoded">
|
<form method="post" action="<?cs var:Config.ScriptName ?>" enctype="application/x-www-form-urlencoded">
|
||||||
<ul>
|
<ul>
|
||||||
<li>noch nicht implementiert</li>
|
<li><input type="checkbox" id="is_vac" name="vacation_enabled" <?cs
|
||||||
<!--
|
if:Data.isVacation ?>checked="checked"<?cs /if ?> />
|
||||||
<li><label for="oldpw"><?cs var:html_escape(Lang.Misc.OldPassword) ?>:</label>
|
<label for="is_vac"><?cs var:html_escape(Lang.Misc.Vacation)
|
||||||
<input type="password" name="oldpassword" id="oldpw" size="20"></li>
|
?></label></li>
|
||||||
-->
|
<li><label><?cs var:html_escape(Lang.Misc.VacationText) ?>:</label>
|
||||||
|
<ul><li>
|
||||||
|
<textarea name="vacation_text" id="vac_text" cols="72" rows="5"><?cs
|
||||||
|
var:html_escape(Data.VacationText) ?></textarea>
|
||||||
|
</li></ul></li>
|
||||||
|
<li><label for="pw"><?cs var:html_escape(Lang.Misc.Password) ?>:</label>
|
||||||
|
<input type="password" name="pw" id="pw" size="20" /></li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue