1 | #!/usr/bin/env python
|
---|
2 | #
|
---|
3 | # Copyright (C) Matthieu Patou <mat@matws.net> 2010
|
---|
4 | #
|
---|
5 | #
|
---|
6 | # This program is free software; you can redistribute it and/or modify
|
---|
7 | # it under the terms of the GNU General Public License as published by
|
---|
8 | # the Free Software Foundation; either version 3 of the License, or
|
---|
9 | # (at your option) any later version.
|
---|
10 | #
|
---|
11 | # This program is distributed in the hope that it will be useful,
|
---|
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | # GNU General Public License for more details.
|
---|
15 | #
|
---|
16 | # You should have received a copy of the GNU General Public License
|
---|
17 | # along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
18 |
|
---|
19 |
|
---|
20 | __docformat__ = "restructuredText"
|
---|
21 |
|
---|
22 |
|
---|
23 | import optparse
|
---|
24 | import sys
|
---|
25 | # Allow to run from s4 source directory (without installing samba)
|
---|
26 | sys.path.insert(0, "bin/python")
|
---|
27 |
|
---|
28 | import samba.getopt as options
|
---|
29 | from samba.credentials import DONT_USE_KERBEROS
|
---|
30 | from samba.auth import system_session
|
---|
31 | from samba import param
|
---|
32 | from samba.provision import find_provision_key_parameters
|
---|
33 | from samba.upgradehelpers import (get_paths,
|
---|
34 | get_ldbs,
|
---|
35 | update_machine_account_password)
|
---|
36 |
|
---|
37 | parser = optparse.OptionParser("chgtdcpass [options]")
|
---|
38 | sambaopts = options.SambaOptions(parser)
|
---|
39 | parser.add_option_group(sambaopts)
|
---|
40 | parser.add_option_group(options.VersionOptions(parser))
|
---|
41 | credopts = options.CredentialsOptions(parser)
|
---|
42 | parser.add_option_group(credopts)
|
---|
43 |
|
---|
44 | opts = parser.parse_args()[0]
|
---|
45 |
|
---|
46 | lp = sambaopts.get_loadparm()
|
---|
47 | smbconf = lp.configfile
|
---|
48 | creds = credopts.get_credentials(lp)
|
---|
49 | creds.set_kerberos_state(DONT_USE_KERBEROS)
|
---|
50 |
|
---|
51 |
|
---|
52 | if __name__ == '__main__':
|
---|
53 | paths = get_paths(param, smbconf=smbconf)
|
---|
54 | session = system_session()
|
---|
55 |
|
---|
56 | ldbs = get_ldbs(paths, creds, session, lp)
|
---|
57 | ldbs.startTransactions()
|
---|
58 |
|
---|
59 | names = find_provision_key_parameters(ldbs.sam, ldbs.secrets, ldbs.idmap,
|
---|
60 | paths, smbconf, lp)
|
---|
61 |
|
---|
62 | update_machine_account_password(ldbs.sam, ldbs.secrets, names)
|
---|
63 | ldbs.groupedCommit()
|
---|