3 # script to test the dnsserver RPC protocol
6 from optparse
import OptionParser
8 sys
.path
.insert(0, "bin/python")
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()
25 print("Usage: dnsserver.py [options] DNSSERVER DNSZONE NEWNAME")
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,
54 print("adding a NS glue record")
55 name
= dnsserver
.DNS_RPC_NAME()
58 addrec
= dnsserver
.DNS_RPC_RECORD()
59 addrec
.wType
= dnsp
.DNS_TYPE_NS
62 addrec
.dwTtlSeconds
= 3600
63 addrec
.dwTimeStamp
= 0
67 addrecbuf
= dnsserver
.DNS_RPC_RECORD_BUF()
68 addrecbuf
.rec
= addrec
70 res
= dns_conn
.DnssrvUpdateRecord2(0x00070000,
79 print("querying the NS record")
80 res
= dns_conn
.DnssrvEnumRecords2(0x00070000,