smbtorture: expand test test_lease_unlink() with set-delete-on-close
[samba4-gss.git] / python / examples / dnsserver.py
blobcaca9980b660d22f8ab9672662775c72cf756966
1 #!/usr/bin/env python3
3 # script to test the dnsserver RPC protocol
5 import sys
6 from optparse import OptionParser
8 sys.path.insert(0, "bin/python")
10 import samba.getopt as options
11 from samba.dcerpc import dnsserver, dnsp
14 ########### main code ###########
15 if __name__ == "__main__":
16 parser = OptionParser("dnsserver [options] server")
17 sambaopts = options.SambaOptions(parser)
18 credopts = options.CredentialsOptionsDouble(parser)
19 parser.add_option_group(credopts)
21 (opts, args) = parser.parse_args()
23 if len(args) < 3:
24 print("Usage: dnsserver.py [options] DNSSERVER DNSZONE NEWNAME")
25 sys.exit(1)
27 server = args[0]
28 dnszone = args[1]
29 newname = args[2]
31 lp = sambaopts.get_loadparm()
32 creds = credopts.get_credentials(lp)
34 if not creds.authentication_requested():
35 parser.error("You must supply credentials")
37 binding_str = "ncacn_ip_tcp:%s[print,sign]" % server
39 dns_conn = dnsserver.dnsserver(binding_str, lp, creds)
41 print("querying a NS record")
42 dns_conn.DnssrvEnumRecords2(0x00070000,
44 server,
45 dnszone,
46 newname,
47 None,
48 dnsp.DNS_TYPE_NS,
49 0x0f,
50 None,
51 None)
53 print("adding a NS glue record")
54 name = dnsserver.DNS_RPC_NAME()
55 name.str = newname
57 addrec = dnsserver.DNS_RPC_RECORD()
58 addrec.wType = dnsp.DNS_TYPE_NS
59 addrec.dwFlags = 0
60 addrec.dwSerial = 0
61 addrec.dwTtlSeconds = 3600
62 addrec.dwTimeStamp = 0
63 addrec.dwReserved = 0
64 addrec.data = name
66 addrecbuf = dnsserver.DNS_RPC_RECORD_BUF()
67 addrecbuf.rec = addrec
69 dns_conn.DnssrvUpdateRecord2(0x00070000,
71 server,
72 dnszone,
73 newname,
74 addrecbuf,
75 None)
77 print("querying the NS record")
78 dns_conn.DnssrvEnumRecords2(0x00070000,
80 server,
81 dnszone,
82 newname,
83 None,
84 dnsp.DNS_TYPE_NS,
85 0x0f,
86 None,
87 None)