torture: Make sure that fruit_ftruncate only unlinks streams
[Samba.git] / source4 / scripting / devel / crackname
blob2e1798511f3b6ac04dde2657cae4f44973a53699
1 #!/usr/bin/env python
3 # Copyright Matthieu Patou <mat@matws.net> 2011
4 # script to call a DRSUAPI crackname
5 # this is useful for plugfest testing and replication debug
7 import sys
8 from optparse import OptionParser
10 sys.path.insert(0, "bin/python")
12 import samba.getopt as options
13 from samba.dcerpc import drsuapi, misc
15 def do_DsBind(drs):
16 '''make a DsBind call, returning the binding handle'''
17 bind_info = drsuapi.DsBindInfoCtr()
18 bind_info.length = 28
19 bind_info.info = drsuapi.DsBindInfo28()
20 bind_info.info.supported_extensions = 0
21 (info, handle) = drs.DsBind(misc.GUID(drsuapi.DRSUAPI_DS_BIND_GUID), bind_info)
22 return handle
25 ########### main code ###########
26 if __name__ == "__main__":
27 parser = OptionParser("crackname server [options]")
28 sambaopts = options.SambaOptions(parser)
29 parser.add_option_group(sambaopts)
30 credopts = options.CredentialsOptionsDouble(parser)
31 parser.add_option_group(credopts)
33 parser.add_option("", "--name", type='str',
34 default='{ED9F5546-9729-4B04-9385-3FCFE2B17BA1}', help="name to crack")
35 parser.add_option("", "--outformat", type='int',
36 default=drsuapi.DRSUAPI_DS_NAME_FORMAT_FQDN_1779,
37 help='format desired')
38 parser.add_option("", "--informat", type='int',
39 default=drsuapi.DRSUAPI_DS_NAME_FORMAT_GUID,
40 help='format offered')
42 (opts, args) = parser.parse_args()
44 lp = sambaopts.get_loadparm()
45 creds = credopts.get_credentials(lp)
47 if len(args) != 1:
48 parser.error("You must supply a server")
50 if creds.is_anonymous():
51 parser.error("You must supply credentials")
53 server = args[0]
55 binding_str = "ncacn_ip_tcp:%s[seal,print]" % server
57 drs = drsuapi.drsuapi(binding_str, lp, creds)
58 drs_handle = do_DsBind(drs)
59 print "DRS Handle: %s" % drs_handle
61 req = drsuapi.DsNameRequest1()
62 names = drsuapi.DsNameString()
63 names.str = opts.name
65 req.codepage = 1252
66 req.language = 1033
67 req.format_flags = 0
68 req.format_offered = opts.informat
69 req.format_desired = opts.outformat
70 req.count = 1
71 req.names = [names]
73 (result, ctr) = drs.DsCrackNames(drs_handle, 1, req)
74 print "# of result = %d" %ctr.count
75 if ctr.count:
76 print "status = %d" % ctr.array[0].status
77 print "result name = %s" % ctr.array[0].result_name
78 print "domain = %s" % ctr.array[0].dns_domain_name