ChangeIP.com Forums

A User-to-User Dynamic DNS Forum
* Grand Reopening! *
Grand Reopening!
It is currently 23 Nov 2008 02:05

All times are UTC - 8 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: programmatically add new host in DNS using vb.net
PostPosted: 18 May 2006 02:08 
Junior Member

Joined: 18 May 2006 02:04
Posts: 3
hi all,

i face a problem now ......i would like to programmatically add new host to DNS using vb.net ....

does anyone have an idea to solve this problem, if possible try to paste the sample code here.

thanks


Top
 Profile  
 
 Post subject: programmatically add new host in DNS using vb.net
PostPosted: 18 May 2006 19:07 
Junior Member

Joined: 18 May 2006 02:04
Posts: 3
hi .....i am using the code below to add new host in DNS....but it return me an error 'Generic Failure'

may i know what is the problem of this code.........

Dim DnsServer As String = \"10.0.1.3\"

Dim conOptions As ConnectionOptions = New ConnectionOptions
conOptions.Authentication = AuthenticationLevel.Packet
conOptions.Impersonation = ImpersonationLevel.Impersonate
Dim sServerPath As String = \"\\\\\" & DnsServer & \"\\root\\microsoftdns\"
Dim oScope As ManagementScope = New ManagementScope(sServerPath, conOptions)
oScope.Connect()
Dim oQuery As ManagementObjectSearcher = New ManagementObjectSearcher(\"SELECT * FROM MicrosoftDNS_AType\")
oQuery.Scope = oScope
Dim oClass As ManagementClass = New ManagementClass(oScope, New ManagementPath(\"MicrosoftDNS_AType\"), Nothing)
Dim oInParams As ManagementBaseObject = oClass.GetMethodParameters(\"CreateInstanceFromPropertyData\")
oInParams(\"DnsServerName\") = DnsServer
oInParams(\"ContainerName\") = \"Mycomcity\"
oInParams(\"OwnerName\") = \"Mycomcity.dev.ss.lan\"
oInParams(\"IPAddress\") = \"10.0.1.3\"
Dim oOutParams As ManagementBaseObject = oClass.InvokeMethod(\"CreateInstanceFromPropertyData\", oInParams, Nothing)

and is this code is correct to create new host in DNS...

thanks


Top
 Profile  
 
 Post subject:
PostPosted: 21 May 2006 23:29 
Junior Member

Joined: 18 May 2006 02:04
Posts: 3
hi,

if anyone got sample code which use WMI to solve this problem .........pls let me know.......cos i might want to try to solve it by using WMI also....

thanks


Top
 Profile  
 
 Post subject:
PostPosted: 20 Nov 2006 06:33 
Junior Member

Joined: 20 Nov 2006 04:38
Posts: 1
Hi!

I've got sample code in C#:
Code:
public void CreateHostSameAsParent()
{
   try
   {
      ManagementScope scope = new ManagementScope( \"\\\\\\\\.\\\\root\\\\MicrosoftDNS\" );
      ManagementClass classInstance = new ManagementClass( scope, new ManagementPath( \"MicrosoftDNS_AType\" ), null );

      ManagementBaseObject inParams =   classInstance.GetMethodParameters( \"CreateInstanceFromPropertyData\" );

      inParams[\"ContainerName\"] = \"xxxx.com\";
      inParams[\"DnsServerName\"] = \"myserver\";
      inParams[\"IPAddress\"] = \"0.0.0.0\";
      inParams[\"OwnerName\"] = \"xxxx.com\";
      inParams[\"RecordClass\"] = 1;

      ManagementBaseObject outParams = classInstance.InvokeMethod( \"CreateInstanceFromPropertyData\", inParams, null );

   }
   catch ( ManagementException err )
   {
      MessageBox.Show( \"An error occurred while trying to execute the WMI method: \" + err.Message );
   }
}



Bye,
Lasso
www.webdot.hu
webdesign, developing, web hosting automation


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2008 phpBB Group

We use phpbb-seo to help us!