Skip to content

Instantly share code, notes, and snippets.

@tpokorra
Last active June 6, 2019 09:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tpokorra/5a6ceb85d0bbca10e03e290b9fb8b772 to your computer and use it in GitHub Desktop.
Save tpokorra/5a6ceb85d0bbca10e03e290b9fb8b772 to your computer and use it in GitHub Desktop.
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
Copy link

naigamo 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