OK, I'm not really getting further with this, this is how far I got:

from ipaserver.plugins.user import user
from ipaserver.plugins.user import user_add
from ipalib import api, cli, Str, _


def your_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
    assert isinstance(dn, DN)

    super(user_add, self).pre_callback(ldap, dn,
        entry_attrs, attrs_list, *keys, **options)

    print("it's here")
    # orig_entry_attrs = ldap.get_entry(dn, ['customPerson'])
    # entry_attrs['customPerson'] = orig_entry_attrs['customPerson']
    # entry_attrs['customPerson'].append(entry_attrs['mailstoragepath'])


user.takes_params += (
    Str('mailstoragepath*',
        cli_name='mailstoragepath',
        label=_('Email Storage Path'),
    ),
)

user.possible_objectclasses.append('customPerson')
user.default_attributes.append('mailstoragepath')

# This errors on a IPA restart when uncommented
#user.user_add.register_pre_callback(your_callback)

----------------------------------------------------------------------


>>> api.Command['user_add'](sn='test_1', givenname='name of test1', 
>>> uid='test_1', mailstoragepath='candy')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/lib/python3.6/site-packages/ipalib/frontend.py", line 450, in 
__call__
    return self.__do_call(*args, **options)
  File "/usr/lib/python3.6/site-packages/ipalib/frontend.py", line 464, in 
__do_call
    params = self.args_options_2_params(*args, **options)
  File "/usr/lib/python3.6/site-packages/ipalib/frontend.py", line 531, in 
args_options_2_params
    params = dict(self.__options_2_params(options))
  File "/usr/lib/python3.6/site-packages/ipalib/frontend.py", line 564, in 
__options_2_params
    option=unused_keys.pop())
ipalib.errors.OptionError: Unknown option: mailstoragepath


What am I doing wrong here ?

Thanks,

Matt
_______________________________________________
FreeIPA-users mailing list -- freeipa-users@lists.fedorahosted.org
To unsubscribe send an email to freeipa-users-le...@lists.fedorahosted.org

Reply via email to