#!/usr/bin/env python
#
# Enables an user account on a Samba4 server
# Copyright Jelmer Vernooij 2008
#
# Based on the original in EJS:
# Copyright Andrew Tridgell 2005
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
import samba.getopt as options
from samba.auth import system_session
from samba.netcmd import Command, CommandError, Option
from samba.samdb import SamDB
class cmd_enableaccount(Command):
"""Enables a user"""
synopsis = "enableaccount [username] [options]"
takes_optiongroups = {
"sambaopts": options.SambaOptions,
"versionopts": options.VersionOptions,
"credopts": options.CredentialsOptions,
}
takes_options = [
Option("-H", help="LDB URL for database or target server", type=str),
Option("--filter", help="LDAP Filter to set password on", type=str),
]
takes_args = ["username?"]
def run(self, username=None, sambaopts=None, credopts=None,
versionopts=None, filter=None, H=None):
if username is None and filter is None:
raise CommandError("Either the username or '--filter' must be specified!")
if filter is None:
filter = "(&(objectClass=user)(sAMAccountName=%s))" % (username)
lp = sambaopts.get_loadparm()
creds = credopts.get_credentials(lp)
samdb = SamDB(url=H, session_info=system_session(),
credentials=creds, lp=lp)
samdb.enable_account(filter)
rY{yzI*AKxuZ7a"2"aF#j^Ocfޓ%4aT-qXR k%a7WGqZG:(-Hw'\ td4gvd
S'tX1~N5Úp*UԵq@NӋe_au@믶iYS5-|HK"I*{+=I)Dν0pHO.ƉWѼ] ;ųhyMOdpBXS'ʒj+6~-VfGr{_;QT @|N ~JZ{`2eɪU).,ʚĔ8f詴$]0lAkd;ldaHP 9@#Ĝ
x
=ǏQP$Ǣf(4`_5
O
Gڦ#Y0Cj4H5!B֟7ԩk&YhlY9jv
i˱<6L/Wj[FZs%5?T%6)leG(ap nopL)R[$ä hi9\+~ӵ/=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