G
Guest
Hi,
I am trying to create a CName record on my DNS server. Seems like it
should be easy. I am using WMI. I have created a test asp.net page and put
the code in the code behind. The DNS server is a Windows 2000 box that sits
next to my pc. I have rights on the DNS box and use Remote desktop to admin
it. So here's the problem. When I try to run my code I get a "The RPC
server is unavailable." error.
Here is my code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Management;
public partial class DNSc : System.Web.UI.Page
{
ManagementScope DNS;
ManagementObject DNSSVR;
private string dnsname;
public string sResults = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
new_Zone("myDNSserver", "myDomain.com");
sResults = "DONE";
}
}
void new_Zone(string dnsserver, string domain)
{
ManagementClass MC;
// connect to WMI ****************************** connect to WMI
ConnectionOptions options = new ConnectionOptions();
options.Authentication =
System.Management.AuthenticationLevel.PacketPrivacy;
options.Username = "username";
options.Password = "password";
DNS = new ManagementScope("\\\\" + dnsserver +
"\\root\\microsoftdns",options);
DNSSVR = new ManagementObject(DNS, new
ManagementPath("MicrosoftDNS_Server.Name=\".\""), null);
DNSSVR.Get(); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dnsname = DNSSVR.Site.Name;
// connect to WMI ****************************** connect to WMI
// create MX-record ***************************** create MX-record
MC = new ManagementClass(DNS, new
ManagementPath("MicrosoftDNS_CNAMETYPE"), null);
object[] A2 = { dnsname, domain, domain, 1, 86400, 10, "test." +
domain };
MC.InvokeMethod("CreateInstanceFromPropertyData", A2);
// create MX-record ***************************** create MX-record
}
}
The line where I receive my error is on the "Get()". I put a comment behind
it like this: // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Thank you for any help on this.
Michael.
I am trying to create a CName record on my DNS server. Seems like it
should be easy. I am using WMI. I have created a test asp.net page and put
the code in the code behind. The DNS server is a Windows 2000 box that sits
next to my pc. I have rights on the DNS box and use Remote desktop to admin
it. So here's the problem. When I try to run my code I get a "The RPC
server is unavailable." error.
Here is my code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Management;
public partial class DNSc : System.Web.UI.Page
{
ManagementScope DNS;
ManagementObject DNSSVR;
private string dnsname;
public string sResults = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
new_Zone("myDNSserver", "myDomain.com");
sResults = "DONE";
}
}
void new_Zone(string dnsserver, string domain)
{
ManagementClass MC;
// connect to WMI ****************************** connect to WMI
ConnectionOptions options = new ConnectionOptions();
options.Authentication =
System.Management.AuthenticationLevel.PacketPrivacy;
options.Username = "username";
options.Password = "password";
DNS = new ManagementScope("\\\\" + dnsserver +
"\\root\\microsoftdns",options);
DNSSVR = new ManagementObject(DNS, new
ManagementPath("MicrosoftDNS_Server.Name=\".\""), null);
DNSSVR.Get(); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dnsname = DNSSVR.Site.Name;
// connect to WMI ****************************** connect to WMI
// create MX-record ***************************** create MX-record
MC = new ManagementClass(DNS, new
ManagementPath("MicrosoftDNS_CNAMETYPE"), null);
object[] A2 = { dnsname, domain, domain, 1, 86400, 10, "test." +
domain };
MC.InvokeMethod("CreateInstanceFromPropertyData", A2);
// create MX-record ***************************** create MX-record
}
}
The line where I receive my error is on the "Get()". I put a comment behind
it like this: // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Thank you for any help on this.
Michael.