DNS
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationDNS

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old April 18th, 2004, 05:12 PM
bertnz bertnz is offline
bertnz
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Auckland NZ
Posts: 2 bertnz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via MSN to bertnz
Red face DNS through WMI in .NET

Has anyone got or seen a working example of making DNS modifications (simple deleting and adding of records) through WMI from .NET code.

I have seen a couple of VBScript examples, but would rather do it through VB or C# code if possible?

Is it in fact possible?

Any help would be much appreciated.

thank you

Reply With Quote
  #2  
Old April 19th, 2004, 12:33 AM
SilentRage's Avatar
SilentRage SilentRage is offline
DNS/BIND Guru
Dev Shed Specialist (4000 - 4499 posts)
 
Join Date: Jun 2003
Location: OH, USA
Posts: 4,193 SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level)SilentRage User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 14 h 12 m 19 sec
Reputation Power: 76
Dunno, don't have any experience with MS DNS really, but once I saw a guy mention commandline tools to manage MS DNS. It'd be a simple thing to execute those commandline tools with the necessary parameters to manage things.
__________________
Send me a private message if you would like me to setup your DNS for you for a price of your choosing. This is the preferred method if your DNS needs to be fixed/setup fast and you don't have the time to bounce messages back and forth on a forum. Also, check out these links:

Whois Direct | DNS Crawler | NS Trace | Compare Free DNS Hosts

Reply With Quote
  #3  
Old August 18th, 2004, 07:59 AM
PrivateJson PrivateJson is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Denmark
Posts: 23 PrivateJson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I've got a complete web-interface build using WMI from .NET to access the DNS (and IIS). What do you need it for?

regards,
Steen

Reply With Quote
  #4  
Old August 30th, 2004, 01:44 PM
crizzo crizzo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 3 crizzo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Steen, if you could help, it would be great. I have a complete vbscript version that I wrote, to modify dns records, and I wanted to convert it to c# (more just to get up to speed on c#).

Anyways, I have the dns record additions working, but I can't figure out how to delete records. If you know how to do this, please let me know, or point me to a site with some info. THANKS!!!!!

Reply With Quote
  #5  
Old August 30th, 2004, 03:54 PM
PrivateJson PrivateJson is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Denmark
Posts: 23 PrivateJson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by crizzo
Steen, if you could help, it would be great. I have a complete vbscript version that I wrote, to modify dns records, and I wanted to convert it to c# (more just to get up to speed on c#).

Anyways, I have the dns record additions working, but I can't figure out how to delete records. If you know how to do this, please let me know, or point me to a site with some info. THANKS!!!!!


Do you know how to select (with query) a ResourceRecord??

Using a ManagementObjectSearcher and getting a ManagementCollection. Run through the collection and delete the record using the Delete method on the ManagementObject class.

Did that make any sence to you?

/Steen

Reply With Quote
  #6  
Old August 30th, 2004, 05:45 PM
crizzo crizzo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 3 crizzo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yes, I have a wmi based nslookup that I was using in my vbscript that I ported over to c# ...It works great, but the delete does not seem to work ....still working on it. (I should probably just use a gethostbyname, but this works very well) By the way, here is part of the nslookup code...

ManagementScope oMs = new ManagementScope("\\\\" + dnsServer + "\\root\\microsoftdns");
string strQuery = "select recorddata from microsoftdns_" + recType +
"type where containername = '" + domain + "' and ownername = '" + strValue + "'";

ObjectQuery oQ = new ObjectQuery(strQuery);
ManagementObjectSearcher oS = new ManagementObjectSearcher(oMs, oQ);
ManagementObjectCollection oRc = oS.Get();
foreach (ManagementObject oR in oRc)
{
temp = oR["recorddata"].ToString();
if (temp.Length == 0) { break; }
}
if (temp == "") { temp = "none"; }

return temp;

Reply With Quote
  #7  
Old August 31st, 2004, 01:05 AM
PrivateJson PrivateJson is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Denmark
Posts: 23 PrivateJson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by crizzo
Yes, I have a wmi based nslookup that I was using in my vbscript that I ported over to c# ...It works great, but the delete does not seem to work ....still working on it. (I should probably just use a gethostbyname, but this works very well) By the way, here is part of the nslookup code...

ManagementScope oMs = new ManagementScope("\\\\" + dnsServer + "\\root\\microsoftdns");
string strQuery = "select recorddata from microsoftdns_" + recType +
"type where containername = '" + domain + "' and ownername = '" + strValue + "'";

ObjectQuery oQ = new ObjectQuery(strQuery);
ManagementObjectSearcher oS = new ManagementObjectSearcher(oMs, oQ);
ManagementObjectCollection oRc = oS.Get();
foreach (ManagementObject oR in oRc)
{
temp = oR["recorddata"].ToString();
if (temp.Length == 0) { break; }
}
if (temp == "") { temp = "none"; }

return temp;


Well, actually you need to do what you've done above, to delete one or more records.

foreach (ManagementObject oR in oRc) {
oR.Delete();
}

That's the way I do it anyway!

/Steen

Reply With Quote
  #8  
Old August 31st, 2004, 01:28 AM
crizzo crizzo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 3 crizzo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I just figured it out. Instead of using the "select recorddata from microsoftdns.."

I use "select * from microsoftdns..."

I was being too specific in my query, so the delete wouldn't work. When I expanded the query to a wildcard, it worked great.

Thanks for all your help on this!!!

Reply With Quote
  #9  
Old February 11th, 2006, 08:10 PM
scorpion53061 scorpion53061 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 1 scorpion53061 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 43 sec
Reputation Power: 0
I need this

I need this to speed up the process of creating accounts PLEASE. Talk to me.....


Quote:
Originally Posted by PrivateJson
I've got a complete web-interface build using WMI from .NET to access the DNS (and IIS). What do you need it for?

regards,
Steen

Reply With Quote
  #10  
Old May 10th, 2006, 06:00 PM
mpoulson-msft mpoulson-msft is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 1 mpoulson-msft User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 39 sec
Reputation Power: 0
What help do you need?

Quote:
Originally Posted by scorpion53061
I need this to speed up the process of creating accounts PLEASE. Talk to me.....



What kind of speed issues are you looking to resolve. Please feel free to email off line or post back.



--
Mike Poulson
http://blogs.msdn.com/mpoulson

Reply With Quote
  #11  
Old May 18th, 2006, 11:18 PM
goh6613 goh6613 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 4 goh6613 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 34 sec
Reputation Power: 0
DNS through WMI in .NET

hi all, i am now facing this problem too.....
i would like to programmatically add new host to the DNS by using WMI (vb.net or c3).

So anyone who got this solution, please kindly post here....

thanks

Reply With Quote
  #12  
Old May 4th, 2008, 02:58 PM
TWDO TWDO is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 1 TWDO User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 33 sec
Reputation Power: 0
Quote:
Originally Posted by goh6613
hi all, i am now facing this problem too.....
i would like to programmatically add new host to the DNS by using WMI (vb.net or c3).

So anyone who got this solution, please kindly post here....

thanks


Does anyone have a complete interface/class in either VB.NET or C# that will handle all the common DNS tasks (createZone, DeleteZone, CreateARecord, CreateMXRecord, etc, etc)?? I would greatly appreciate it.

I would love to just be able to download a working class file.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationDNS > DNS through WMI in .NET


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |