5 # Find right directory when running from source tree
6 sys.path.insert(0, "bin/python")
10 from samba import getopt as options
11 from samba import NTSTATUSError
12 from samba.credentials import Credentials
13 parser = optparse.OptionParser("machineaccountpw")
14 sambaopts = options.SambaOptions(parser)
15 parser.add_option_group(sambaopts)
16 parser.add_option_group(options.VersionOptions(parser))
17 opts, args = parser.parse_args()
24 lp_ctx = sambaopts.get_loadparm()
25 except RuntimeError as error:
26 print("Unable to load smb.conf %s: %s" % (sambaopts.get_loadparm_path(),
35 creds.set_machine_account(lp_ctx)
36 except NTSTATUSError as error:
37 print("Failed to find a stored machine account credential on this system: %s" \
42 print(creds.get_password())