3 # script to test the dnsserver RPC protocol
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()
24 print("Usage: dnsserver.py [options] DNSSERVER DNSZONE NEWNAME")
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,
53 print("adding a NS glue record")
54 name
= dnsserver
.DNS_RPC_NAME()
57 addrec
= dnsserver
.DNS_RPC_RECORD()
58 addrec
.wType
= dnsp
.DNS_TYPE_NS
61 addrec
.dwTtlSeconds
= 3600
62 addrec
.dwTimeStamp
= 0
66 addrecbuf
= dnsserver
.DNS_RPC_RECORD_BUF()
67 addrecbuf
.rec
= addrec
69 dns_conn
.DnssrvUpdateRecord2(0x00070000,
77 print("querying the NS record")
78 dns_conn
.DnssrvEnumRecords2(0x00070000,