1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-08 16:59:09 +03:00

s4-net: nicer error message (and no exception)

in net newuser and net setpasswd we shouldn't be throwing python
exceptions on normal user errors like unknown user

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Andrew Tridgell
2010-04-15 17:14:46 +10:00
parent 22d7a06522
commit 046c5824e4
2 changed files with 17 additions and 5 deletions

View File

@ -21,6 +21,7 @@
import samba.getopt as options
from samba.netcmd import Command, Option
import sys, ldb
from getpass import getpass
from samba.auth import system_session
@ -61,5 +62,10 @@ class cmd_newuser(Command):
samdb = SamDB(url=H, session_info=system_session(), credentials=creds,
lp=lp)
samdb.newuser(username, unixname, password,
force_password_change_at_next_login_req=must_change_at_next_login)
try:
samdb.newuser(username, unixname, password,
force_password_change_at_next_login_req=must_change_at_next_login)
except ldb.LdbError, (num, msg):
print('Failed to create user "%s" : %s' % (username, msg))
sys.exit(1)