s4:credentials Add hooks to extract a named Kerberos credentials cache
[ira/wip.git] / source4 / scripting / bin / machineaccountccache
1 #!/usr/bin/python
2 import optparse
3 import sys
4
5 # Find right directory when running from source tree
6 sys.path.insert(0, "bin/python")
7
8
9 import samba
10 from samba import getopt as options
11 from samba.credentials import Credentials
12 parser = optparse.OptionParser("machineaccountccache <ccache name>")
13 sambaopts = options.SambaOptions(parser)
14 parser.add_option_group(sambaopts)
15 parser.add_option_group(options.VersionOptions(parser))
16 opts, args = parser.parse_args()
17
18 if len(args) != 1:
19     parser.print_usage()
20     sys.exit(1)
21
22 ccachename = args[0]
23
24 lp_ctx = sambaopts.get_loadparm()
25
26 creds = Credentials()
27
28 creds.guess(lp_ctx)
29 creds.set_machine_account(lp_ctx)
30 creds.get_named_ccache(lp_ctx, ccachename)