Changeset View
Changeset View
Standalone View
Standalone View
pykolab/cli/cmd_remove_mailaddress.py
Show All 12 Lines | |||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
# GNU General Public License for more details. | # GNU General Public License for more details. | ||||
# You should have received a copy of the GNU General Public License | # You should have received a copy of the GNU General Public License | ||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
# | # | ||||
from __future__ import print_function | from __future__ import print_function | ||||
from six import string_types | |||||
import sys | import sys | ||||
import commands | import commands | ||||
import pykolab | import pykolab | ||||
from pykolab.auth import Auth | from pykolab.auth import Auth | ||||
Show All 33 Lines | def execute(*args, **kw): | ||||
log.debug(_("Found the following recipient(s): %r") % (recipients), level=8) | log.debug(_("Found the following recipient(s): %r") % (recipients), level=8) | ||||
mail_attributes = conf.get_list(domain, 'mail_attributes') | mail_attributes = conf.get_list(domain, 'mail_attributes') | ||||
if mail_attributes == None or len(mail_attributes) < 1: | if mail_attributes == None or len(mail_attributes) < 1: | ||||
mail_attributes = conf.get_list(conf.get('kolab', 'auth_mechanism'), 'mail_attributes') | mail_attributes = conf.get_list(conf.get('kolab', 'auth_mechanism'), 'mail_attributes') | ||||
log.debug(_("Using the following mail attributes: %r") % (mail_attributes), level=8) | log.debug(_("Using the following mail attributes: %r") % (mail_attributes), level=8) | ||||
if isinstance(recipients, basestring): | if isinstance(recipients, string_types): | ||||
recipient = recipients | recipient = recipients | ||||
# Only a single recipient found, remove the address | # Only a single recipient found, remove the address | ||||
attributes = auth.get_entry_attributes(domain, recipient, mail_attributes) | attributes = auth.get_entry_attributes(domain, recipient, mail_attributes) | ||||
# See which attribute holds the value we're trying to remove | # See which attribute holds the value we're trying to remove | ||||
for attribute in attributes: | for attribute in attributes: | ||||
if isinstance(attributes[attribute], list): | if isinstance(attributes[attribute], list): | ||||
Show All 17 Lines |