Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import pykolab
from pykolab.translate import _
from pykolab import utils
log = pykolab.getLogger('pykolab.cli')
conf = pykolab.getConf()
def run():
from pykolab import wap_client
wap_client.authenticate()
try:
domain = conf.cli_args.pop(0)
except IndexError, errmsg:
domain = utils.ask_question(_("Domain name, eg. example.org"))
try:
preferredlanguage = conf.cli_args.pop(0)
except IndexError, errmsg:
preferredlanguage = utils.ask_question(_("Preferred language in the Kolab webadmin, eg. de_DE"))
try:
sn = conf.cli_args.pop(0)
except IndexError, errmsg:
sn = utils.ask_question(_("Surname of the new user"))
try:
givenname = conf.cli_args.pop(0)
except IndexError, errmsg:
givenname = utils.ask_question(_("Firstname of the new user"))
try:
password = conf.cli_args.pop(0)
except IndexError, errmsg:
password = utils.ask_question(_("Password of the new user"))
domain_dn='dc='+',dc='.join(domain.split('.'))
newuser={'type_id': '1',
'object_type': 'user',
'objectclass': [u'inetorgperson',
u'kolabinetorgperson',
u'mailrecipient',
u'organizationalperson',
u'person',
u'top'],
'preferredlanguage': preferredlanguage,
'sn': sn,
'givenname': givenname,
'ou': u'ou=people,'+domain_dn,
'userpassword': password,
}
# to avoid aliases to be created from the primary domain
wap_client.system_select_domain(domain)
wap_client.user_add(newuser)
run()
@naigamo

This comment has been minimized.

Copy link

commented Jun 6, 2019

Hot to delete command line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.