Changeset View
Changeset View
Standalone View
Standalone View
pykolab/cli/cmd_add_alias.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 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | def execute(*args, **kw): | ||||
if primary_rcpt_attr not in primary_recipient: | if primary_rcpt_attr not in primary_recipient: | ||||
print(_("Recipient %r is not the primary recipient for address %r") % (primary_recipient, primary_rcpt_address), file=sys.stderr) | print(_("Recipient %r is not the primary recipient for address %r") % (primary_recipient, primary_rcpt_address), file=sys.stderr) | ||||
sys.exit(1) | sys.exit(1) | ||||
if secondary_rcpt_attr not in primary_recipient: | if secondary_rcpt_attr not in primary_recipient: | ||||
auth.set_entry_attributes(primary_rcpt_domain, primary_recipient_dn, {secondary_rcpt_attr: [ secondary_rcpt_address ] }) | auth.set_entry_attributes(primary_rcpt_domain, primary_recipient_dn, {secondary_rcpt_attr: [ secondary_rcpt_address ] }) | ||||
else: | else: | ||||
if isinstance(primary_recipient[secondary_rcpt_attr], basestring): | if isinstance(primary_recipient[secondary_rcpt_attr], string_types): | ||||
new_secondary_rcpt_attrs = [ | new_secondary_rcpt_attrs = [ | ||||
primary_recipient[secondary_rcpt_attr], | primary_recipient[secondary_rcpt_attr], | ||||
secondary_rcpt_address | secondary_rcpt_address | ||||
] | ] | ||||
else: | else: | ||||
new_secondary_rcpt_attrs = \ | new_secondary_rcpt_attrs = \ | ||||
primary_recipient[secondary_rcpt_attr] + \ | primary_recipient[secondary_rcpt_attr] + \ | ||||
Show All 10 Lines |