messaging3: I don't see 2 versions running concurrently...
[Samba.git] / python / examples / dnsserver.py
blobc65b1c409985fe3610e24c9e97d2bf47b7d59739
1 #!/usr/bin/env python
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
11 import samba.getopt as options
12 from samba.dcerpc import dnsserver, security, dnsp
15 ########### main code ###########
16 if __name__ == "__main__":
17 parser = OptionParser("dnsserver [options] server")
18 sambaopts = options.SambaOptions(parser)
19 credopts = options.CredentialsOptionsDouble(parser)
20 parser.add_option_group(credopts)
22 (opts, args) = parser.parse_args()
24 if len(args) < 3:
25 print("Usage: dnsserver.py [options] DNSSERVER DNSZONE NEWNAME")
26 sys.exit(1)
28 server = args[0]
29 dnszone = args[1]
30 newname = args[2]
32 lp = sambaopts.get_loadparm()
33 creds = credopts.get_credentials(lp)
35 if not creds.authentication_requested():
36 parser.error("You must supply credentials")
38 binding_str = "ncacn_ip_tcp:%s[print,sign]" % server
40 dns_conn = dnsserver.dnsserver(binding_str, lp, creds)
42 print("querying a NS record")
43 res = dns_conn.DnssrvEnumRecords2(0x00070000,
45 server,
46 dnszone,
47 newname,
48 None,
49 dnsp.DNS_TYPE_NS,
50 0x0f,
51 None,
52 None)
54 print("adding a NS glue record")
55 name = dnsserver.DNS_RPC_NAME()
56 name.str = newname
58 addrec = dnsserver.DNS_RPC_RECORD()
59 addrec.wType = dnsp.DNS_TYPE_NS
60 addrec.dwFlags = 0
61 addrec.dwSerial = 0
62 addrec.dwTtlSeconds = 3600
63 addrec.dwTimeStamp = 0
64 addrec.dwReserved = 0
65 addrec.data = name
67 addrecbuf = dnsserver.DNS_RPC_RECORD_BUF()
68 addrecbuf.rec = addrec
70 res = dns_conn.DnssrvUpdateRecord2(0x00070000,
72 server,
73 dnszone,
74 newname,
75 addrecbuf,
76 None)
79 print("querying the NS record")
80 res = dns_conn.DnssrvEnumRecords2(0x00070000,
82 server,
83 dnszone,
84 newname,
85 None,
86 dnsp.DNS_TYPE_NS,
87 0x0f,
88 None,
89 None)