# along with this program. If not, see <http://www.gnu.org/licenses/>.
import samba.getopt as options
-from samba.netcmd import Command, Option
-import sys, ldb
+from samba.netcmd import Command, CommandError, Option
+import ldb
from getpass import getpass
from samba.auth import system_session
samdb.newuser(username, 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)
+ raise CommandError('Failed to create user "%s" : %s' % (
+ username, msg))
import samba.getopt as options
from samba.netcmd import Command, CommandError, Option
-import sys
from getpass import getpass
from samba.auth import system_session
from samba.samdb import SamDB
force_change_at_next_login=must_change_at_next_login,
username=username)
except:
- print('Failed to set password for user "%s"' % username)
- sys.exit(1)
-
+ raise CommandError('Failed to set password for user "%s"' %
+ username)