From 36cd823be85890a4e8ce8ef9a6628ed7fa984076 Mon Sep 17 00:00:00 2001 From: mlan Date: Mon, 11 Jan 2021 20:08:00 +0100 Subject: [PATCH] - [kopano](src/kopano/plugin/movetopublicldap.py) Include Kopano copyright and license. --- README.md | 4 ++-- demo/.env | 1 + demo/Makefile | 1 + src/kopano/plugin/movetopublicldap.py | 26 ++++++++++++++++++-------- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 31cca67..8cdbca1 100644 --- a/README.md +++ b/README.md @@ -470,7 +470,7 @@ kopanoResourceType: publicFolder:Public Stores/public ``` messages to `public@example.com` will be delivered to the public store in `Public Stores/public`. -The central [attribute](https://documentation.kopano.io/kopanocore_administrator_manual/appendix_b.html#appendix-b-ldap-attribute-description) is `kopanoResourceType: publicFolder:Public Stores/public`. It contains a token and a folder name. The token match is case sensitive and there must be a colon `:` separating +The central [attribute](https://documentation.kopano.io/kopanocore_administrator_manual/appendix_b.html#appendix-b-ldap-attribute-description) is `kopanoResourceType: publicFolder:Public Stores/public`. It contains a token and a folder name. The token match is case sensitive and there must be a colon `:` separating the token and the public folder name. The folder name can contain space and sub folders, which are distinguished using a forward slash `/`. @@ -483,7 +483,7 @@ ldap_public_folder_attribute = kopanoResourceType ldap_public_folder_attribute_token = publicFolder ``` -As with other parameters, environment variables can be used to define them: `LDAP_PUBLIC_FOLDER_ATTRIBUTE=kopanoResourceType` and `LDAP_PUBLIC_FOLDER_ATTRIBUTE_TOKEN=publicFolder`. +As with other parameters, environment variables can be used to define them: `LDAP_PUBLIC_FOLDER_ATTRIBUTE=kopanoResourceType` and `LDAP_PUBLIC_FOLDER_ATTRIBUTE_TOKEN=publicFolder`. ## Shared folders diff --git a/demo/.env b/demo/.env index 0af278e..9099823 100644 --- a/demo/.env +++ b/demo/.env @@ -16,6 +16,7 @@ LDAP_GROUPOU=groups LDAP_GROUPOBJ=kopano-group LDAP_TEST_USER=demo LDAP_TEST_USERPW=demo +LDAP_TEST_USERAS=trial LDAP_TEST_ADMIN=admin LDAP_TEST_ADMINPW=admin LDAP_TEST_GROUP=team diff --git a/demo/Makefile b/demo/Makefile index b0999e8..1a8526e 100644 --- a/demo/Makefile +++ b/demo/Makefile @@ -149,6 +149,7 @@ userPassword: $(LDAP_TEST_USERPW) telephoneNumber: 0123 123456789 title: First User kopanoAccount: 1 +kopanoAliases: $(LDAP_TEST_USERAS)@$(MAIL_DOMAIN) kopanoEnabledFeatures: imap kopanoEnabledFeatures: pop3 endef diff --git a/src/kopano/plugin/movetopublicldap.py b/src/kopano/plugin/movetopublicldap.py index a93c2f8..c589a50 100644 --- a/src/kopano/plugin/movetopublicldap.py +++ b/src/kopano/plugin/movetopublicldap.py @@ -1,6 +1,10 @@ -""" movetopublicldap.py +# SPDX-License-Identifier: AGPL-3.0-only +""" (c) 2019 Kopano -This is an LDAP lookup extension to the move to public plugin. +movetopublicldap.py + +This is an LDAP lookup extension to the move to public plugin movetopublic.py. +The changes to the original work are highlihgted below. The move to public plugin moves incoming messages to a folder in the public store. If folders are missing they will be created. @@ -40,7 +44,8 @@ import ldap import os.path class KConfigParser(ZConfigParser): - """ Extends zconfig.ZConfigParser to also allow !directive in cfg files """ + """ Extends zconfig.ZConfigParser to also allow !directive in cfg files. + Change type addition. """ def __init__(self, configfile, defaultconfig={}): self.config = configparser.ConfigParser(defaults=defaultconfig, delimiters=('='), comment_prefixes=('#', '!')) @@ -70,7 +75,8 @@ class MoveToPublic(IMapiDAgentPlugin): self.readconfig(self.CONFIGFILES, self.DEFAULTCONFIG) def readconfig(self, configfiles=CONFIGFILES, defaultconfig=DEFAULTCONFIG): - """ Reads ldap.cfg and movetopublicldap.cfg into self.config """ + """ Reads ldap.cfg and movetopublicldap.cfg into self.config. + Change type addition. """ options = [opt.split('_', 1)[1] for opt in defaultconfig.keys()] config = None for configfile in configfiles: @@ -87,7 +93,8 @@ class MoveToPublic(IMapiDAgentPlugin): return self.config def searchfilter(self, recipient): - """ (&(uid=recipient)(kopanoResourceType=publicFolder:*)) """ + """ (&(uid=recipient)(kopanoResourceType=publicFolder:*)). + Change type addition. """ return ("(&({}={})({}={}:*))" .format(self.config['user_unique_attribute'], recipient, @@ -96,8 +103,8 @@ class MoveToPublic(IMapiDAgentPlugin): def searchquery(self, recipient): """ Query a LDAP/AD driectory server to lookup recipient using - search_base and return public_folder_attribute - """ + search_base and return public_folder_attribute. + Change type addition. """ if not self.config or not self.config['uri']: self.logger.logError(("!--- ldap_uri is not defined." " Please check {}" .format(self.CONFIGFILES))) @@ -133,7 +140,8 @@ class MoveToPublic(IMapiDAgentPlugin): return result def publicfolder(self, recipient): - """ Check for ldap_public_folder_attribute_token and return folder """ + """ Check for ldap_public_folder_attribute_token and return folder. + Change type addition. """ destination_folder = [] result = self.searchquery(recipient) if result: @@ -149,6 +157,8 @@ class MoveToPublic(IMapiDAgentPlugin): return destination_folder def PreDelivery(self, session, addrbook, store, folder, message): + """ Original code from movetopublic.py with call to self.publicfolder(). + Change type modification. """ props = message.GetProps([PR_RECEIVED_BY_EMAIL_ADDRESS_W], 0) if props[0].ulPropTag != PR_RECEIVED_BY_EMAIL_ADDRESS_W: