WMI Path Problem

V

vbnetdev

hi all,

This code works to add a nameserver to a container in DNS using vb.net and
WMI. Howeer the code below that to add host records such as WWW and to add
an MX record does not. It ojects with "invalid path" complaints. Any ideas
what I am doing wrong? This is vb.net 2005 and the platform is Windows
Server 2003 SP1.

'code works
Dim classInstance3 As New ManagementObject( _
"root\MicrosoftDNS", _
"MicrosoftDNS_NSType.ContainerName='" &
queryObj("ContainerName") & "',DnsServerName='" & queryObj("DnsServerName")
& "',DomainName='" & queryObj("DomainName") & "',OwnerName='" &
queryObj("OwnerName") & "',RecordClass='" & queryObj("RecordClass") &
"',RecordData='" & queryObj("DnsServerName") & ".'", _
Nothing)

Dim inParamsNS2 As ManagementBaseObject = _
classInstance3.GetMethodParameters("CreateInstanceFromPropertyData")

' Add the input parameters.
inParamsNS2("ContainerName") = queryObj("ContainerName")
inParamsNS2("DnsServerName") = queryObj("DnsServerName")
inParamsNS2("NSHost") = NameserverHost2
inParamsNS2("OwnerName") = queryObj("ContainerName")
inParamsNS2("RecordClass") = queryObj("RecordClass")
inParamsNS2("TTL") = TTL

Dim outParamsNS2 As ManagementBaseObject = _
classInstance3.InvokeMethod("CreateInstanceFromPropertyData",
inParamsNS2, Nothing)



'does not work to add host record - invalid path or method not found. This
is the first host record being added. The owner name field troubles me. It
seems to refer to a presently existing host record though none exists yet. I
tried (OwnerName=" & Nothing & ", etc). I reverted to hard coding for
demonstrating here. thank you for any help.



Dim classInstance As New ManagementObject( _
"root\MicrosoftDNS", _
"MicrosoftDNS_AType.ContainerName='zz.com',DnsServerName='w2k3.JJK.ds.',DomainName='zz.com',OwnerName='zz.com',RecordClass='1',RecordData='155.155.1.143'",
_
Nothing)

' Obtain [in] parameters for the method
Dim inParams As ManagementBaseObject = _
classInstance.GetMethodParameters("CreateInstanceFromPropertyData")

' Add the input parameters.
inParams("ContainerName") = "zz.com"
inParams("DnsServerName") = "myserver.DOMAINNAME.ds."
inParams("IPAddress") = "10.10.10.10"
inParams("OwnerName") = "ftp"
inParams("RecordClass") = 1
inParams("TTL") = 3600

Dim outParams As ManagementBaseObject = _
classInstance.InvokeMethod("CreateInstanceFromPropertyData",
inParams, Nothing)

' List outParams
Console.WriteLine("Out parameters:")
Console.WriteLine("RR: {0}", outParams("RR"))

Catch err As ManagementException

MessageBox.Show("An error occurred while trying to execute
the WMI method: " & err.Message)
End Try
 
G

Gary Chang[MSFT]

Hi,
The owner name field troubles me. It seems to refer to a
presently existing host record though none exists yet.

I think you need to provide a valid server name for the owner name field,
please refer to the sample script in the following technet link:

Create a Name Server DNS Record
http://www.microsoft.com/technet/scriptcenter/scripts/network/dns/records/nw
revb08.mspx

By the way, this is not VB.NET issue, if you have any problem while running
the above sample, I suggest you can consult this issue in some networking
related MSDN newsgroup,you'd get better and quicker help there.

Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Community Support
======================================================
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00
AM PST, February 14, 2006. Please complete a re-registration process by
entering the secure code mmpng06 when prompted. Once you have entered the
secure code mmpng06, you will be able to update your profile and access the
partner newsgroups.
======================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
 
V

vbnetdev

I have to disagree.
This code executes perfectly well when an A record already exists such as
"*". If none exists it gives the invalid method or path not found.

We are not creating a nameserver. We are creating a host record for the
zone.

Please follow up. Thank you.

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com



"Gary Chang[MSFT]" said:
Hi,
The owner name field troubles me. It seems to refer to a
presently existing host record though none exists yet.

I think you need to provide a valid server name for the owner name field,
please refer to the sample script in the following technet link:

Create a Name Server DNS Record
http://www.microsoft.com/technet/scriptcenter/scripts/network/dns/records/nw
revb08.mspx

By the way, this is not VB.NET issue, if you have any problem while
running
the above sample, I suggest you can consult this issue in some networking
related MSDN newsgroup,you'd get better and quicker help there.

Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Community Support
======================================================
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00
AM PST, February 14, 2006. Please complete a re-registration process by
entering the secure code mmpng06 when prompted. Once you have entered the
secure code mmpng06, you will be able to update your profile and access
the
partner newsgroups.
======================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
======================================================
 
V

vbnetdev

This code successfully created the host record "htp" in abc.com even though
no previous host record existed. It was done by referring to another
existing domain in the select statement. However at the end it reported a
"generic error". No further explanation was given.

Please advise....

Dim classInstance As New ManagementObject(scope, _
New
ManagementPath("MicrosoftDNS_AType.ContainerName='existingdomain.com',DnsServerName='server.DOMAIN.ds',DomainName='existingdomain.com',OwnerName='www.existingdomain.com',RecordClass='1',RecordData='10.10.10.10'"),
_
Nothing)

' Obtain [in] parameters for the method
Dim inParams As ManagementBaseObject = _
classInstance.GetMethodParameters("CreateInstanceFromPropertyData")

' Add the input parameters.
inParams("ContainerName") = "abc.com"
inParams("DnsServerName") = "server.DOMAIN.ds"
inParams("IPAddress") = "10.10.10.10"
inParams("OwnerName") = "htp"
inParams("RecordClass") = 1
inParams("TTL") = 3600


' Execute the method and obtain the return values.
Dim outParams As ManagementBaseObject = _
classInstance.InvokeMethod("CreateInstanceFromPropertyData",
inParams, Nothing)

' List outParams
MsgBox("RR: {0}", outParams("RR"))

Close()

Catch err As ManagementException

MessageBox.Show("An error occurred while trying to execute the
WMI method: " & err.Message)

End Try

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com



vbnetdev said:
I have to disagree.
This code executes perfectly well when an A record already exists such as
"*". If none exists it gives the invalid method or path not found.

We are not creating a nameserver. We are creating a host record for the
zone.

Please follow up. Thank you.

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com



"Gary Chang[MSFT]" said:
Hi,
The owner name field troubles me. It seems to refer to a
presently existing host record though none exists yet.

I think you need to provide a valid server name for the owner name field,
please refer to the sample script in the following technet link:

Create a Name Server DNS Record
http://www.microsoft.com/technet/scriptcenter/scripts/network/dns/records/nw
revb08.mspx

By the way, this is not VB.NET issue, if you have any problem while
running
the above sample, I suggest you can consult this issue in some networking
related MSDN newsgroup,you'd get better and quicker help there.

Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Community Support
======================================================
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at
9:00
AM PST, February 14, 2006. Please complete a re-registration process by
entering the secure code mmpng06 when prompted. Once you have entered the
secure code mmpng06, you will be able to update your profile and access
the
partner newsgroups.
======================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
======================================================
 
G

Gary Chang[MSFT]

Hi,

I am sorry I must have misunderstood your original question. You just need
to create a host record instead of a Name Server DNS Record. The script
sample I suggested does not target on your problem.
It was done by referring to another existing domain in the
select statement. However at the end it reported a
"generic error". No further explanation was given.

Currently the scenario is you can add a host record even when no host
record exists in the DNS zone, but you got a "generic error" in the end.
Please correct me if I have misunderstood anything.

Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Community Support
======================================================
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00
AM PST, February 14, 2006. Please complete a re-registration process by
entering the secure code mmpng06 when prompted. Once you have entered the
secure code mmpng06, you will be able to update your profile and access the
partner newsgroups.
======================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
 
V

vbnetdev

Gary,

Misunderstandings happen. I appreciate you coming back.

I can add host record but I must reference a zone that contains an already
existing host record.

Here I am accessing the already existing zone and a host record in it:
ManagementPath("MicrosoftDNS_AType.ContainerName='existingdomain.com',DnsServerName='server.DOMAIN.ds',DomainName='existingdomain.com',OwnerName='www.existingdomain.com',RecordClass='1',RecordData='10.10.10.10'"),
It was the only way I found to add a host record to a zone that does not
have any. I do so with these parameters.

' Add the input parameters.
inParams("ContainerName") = "abc.com"
inParams("DnsServerName") = "server.DOMAIN.ds"
inParams("IPAddress") = "10.10.10.10"
inParams("OwnerName") = "htp"
inParams("RecordClass") = 1
inParams("TTL") = 3600

At the end, I get a "generic error" which although it appears, the host
record does in fact get created. I can deal with it since I call tell the
exception handler to ignore these errors. However, I didnt feel it was good
coding practice to do so.

Dim outParams As ManagementBaseObject = _
classInstance.InvokeMethod("CreateInstanceFromPropertyData",
inParams, Nothing)

Kelly
--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com



"Gary Chang[MSFT]" said:
Hi,

I am sorry I must have misunderstood your original question. You just need
to create a host record instead of a Name Server DNS Record. The script
sample I suggested does not target on your problem.
It was done by referring to another existing domain in the
select statement. However at the end it reported a
"generic error". No further explanation was given.

Currently the scenario is you can add a host record even when no host
record exists in the DNS zone, but you got a "generic error" in the end.
Please correct me if I have misunderstood anything.

Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Community Support
======================================================
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00
AM PST, February 14, 2006. Please complete a re-registration process by
entering the secure code mmpng06 when prompted. Once you have entered the
secure code mmpng06, you will be able to update your profile and access
the
partner newsgroups.
======================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
======================================================
 
G

Gary Chang[MSFT]

Hi Kelly,

Thanks for your confirmation, we have already contacted our WMI specialists
to look into this issue. We will update you as soon as we get anything out.

Thanks for your understanding!


Best regards,

Gary Chang
Microsoft Community Support
======================================================
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00
AM PST, February 14, 2006. Please complete a re-registration process by
entering the secure code mmpng06 when prompted. Once you have entered the
secure code mmpng06, you will be able to update your profile and access the
partner newsgroups.
======================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
 
M

Max L. Vaughn [MSFT]

We've seen the generic error message before when adding records to the DNS
server. In the past, we've suggested that customer not set the TTL
attribute to a specific value, but rather let it default to the DNS server
default value.

Try changing the line: inParams("TTL")=3600 to inParams("TTL")=0

There are a wide variety of DNS management Samples. Have you had the
opportunity to review these samples:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dns/dns/dns
_wmi_provider_scripting_examples.asp?frame=true

The examples contain a sample of how to add a resource record without
having to perform a query.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dns/dns/dns
_wmi_provider_samples_managing_dns_resource_records.asp?frame=true#_dns_add_
a_resource_record


The access denied error could be generated by a couple of different issues.

1. Check to make sure that the credentials being used to modify the DNS are
members of the Local Administrators group on the DNS server.
2. Check the WMI permissions and make sure that the "Local Administrators"
or Administrators group has launch permissions, you can use 'WMI Control"
snapin to view WMI permisisons.
3. Verify the DCOM permissions, make sure the "Local Administrators" or
Adminsitrators group has permission to launch and execute objects on the
DNS target.

Sincerely,
Max Vaughn [MS]
Microsoft Developer Support, Windows Systems - Managed Technologies


Disclaimer: This posting is provided "AS IS" with no warranties, and
confers no rights. You assume all risk for your use.
 
V

vbnetdev

Max,

Yes I have saw those samples. While they were helpful in some respects to me
originally converting the code to vb.net was in many cases problematic as I
am sure you know.

I will try changing the params line like you said and see if the generic
error goes away.

If I handle the exception to tell it to ignore "generic errors" how would
you feel about that?

-
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com
 
V

vbnetdev

Max,

Is there a vb.net version of this code? Or do I need to try to do unmanaged
calls to do these scripts?
 
M

Max L. Vaughn [MSFT]

This is looking a bit more detailed than what can be convered in a
newsgroup posting.

I would suggest created a support incident so we can address your questions
on a more direct level.

To answer your question about the DNS samples in VB.Net. We do not have
any canned DNS samples written in VB.Net. What we can do is forward the
request to the product group and start the process of creating them. The
DNS provider is a relatively new and the samples creation has not kept up
with the sample demand.

Sincerely,
Max Vaughn [MS]
Microsoft Developer Support, MCP, MCAD
Windows Managed Technologies


Disclaimer: This posting is provided "AS IS" with no warranties, and
confers no rights. You assume all risk for your use.
 
V

vbnetdev

Will I get charged for this?

Understand the context of these remarks. I still love .NET. My back is
against the wall and this is frustrating.

The reason I ask is that we made a decision as a business to pursue the road
of .NET development as the future course of where our business would go.
Even my side business I started on this premise.
We sink thousands of dollars into development environemnts, books, tools all
to make things happen with .NET. Is it a reflection of me as being a poor
developer? I would like not to think so. I woudl like to think that given
time and the ability to research a given problem the answers will be there.
And I will find them. But the answers are not out there.

But the thing is when I started learning .NET it was a hobby, a toy. If it
worked great, if it didn't oh well, no big deal. That is no longer the case.
Today I have deadlines and requirements and I am expected to deliver. .NET
is no longer considered "not for production use" and if the documentation or
tools is incomplete this is not a good situation for a "production use"
software or framework.

I know if I were to write code and fail to provide complete documentation
and such my employement here would be very much in doubt.

Anyway let me know if I am going to be charged for this or have to spend one
of my support incidents. And again forgive my frustration.
 
M

Max L. Vaughn [MSFT]

I can't say if you'll be charged for the incident or not. It depends on
what you need, and what your question is exactly.

If you have an MSDN subscription, Pro-Pack of support incidents or a even
better, a primeir support contract, you could create an incident looking
for information on why you are getting the Generic Failure when you create
your DNS record.

I would test creating the records using WMI from VBS first, just to make
sure you get the same error. You may find that its as simple as figuring
out the appropriate argument values.

The WMI documentation does provide a variety of information on DNS topics,
its not always as clear as its needs to be.

At any rate, once your issue has been routed to the appropriate team, and
once you have received resolution to your issue, then you can discuss with
the Support Engineer the prospects of marking the incident non decrement.

The chances are very good that you will be working with one of my team
members. If you mention that your issue started as a newsgroup support
issue and you spoke with me, I'll be happy to provide a bit of history and
act as a advecate for you.

Sincerely,
Max Vaughn [MS], MCP, MCAD
Microsoft Developer Support


Disclaimer: This posting is provided "AS IS" with no warranties, and
confers no rights. You assume all risk for your use.
 
O

Oliver

I'm not sure what you're trying to do exactly with your script, but if
you're looking to add an A_record via vb.net, I have successfully
gotten it to work. I'm currently working on a whole class of DNS
management tools to be used in .NET. What is your goal for your
script? Simply to create an A record?

Oliver Melisiotis
CosmoTek.Net .NET Hosting
--> www.cosmotek.net
--> (e-mail address removed)

Will I get charged for this?

Understand the context of these remarks. I still love .NET. My back is
against the wall and this is frustrating.

The reason I ask is that we made a decision as a business to pursue the road
of .NET development as the future course of where our business would go.
Even my side business I started on this premise.
We sink thousands of dollars into development environemnts, books, tools all
to make things happen with .NET. Is it a reflection of me as being a poor
developer? I would like not to think so. I woudl like to think that given
time and the ability to research a given problem the answers will be there.
And I will find them. But the answers are not out there.

But the thing is when I started learning .NET it was a hobby, a toy. If it
worked great, if it didn't oh well, no big deal. That is no longer the case.
Today I have deadlines and requirements and I am expected to deliver. .NET
is no longer considered "not for production use" and if the documentation or
tools is incomplete this is not a good situation for a "production use"
software or framework.

I know if I were to write code and fail to provide complete documentation
and such my employement here would be very much in doubt.

Anyway let me know if I am going to be charged for this or have to spend one
of my support incidents. And again forgive my frustration.


--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com



Max L. Vaughn said:
This is looking a bit more detailed than what can be convered in a
newsgroup posting.

I would suggest created a support incident so we can address your
questions
on a more direct level.

To answer your question about the DNS samples in VB.Net. We do not have
any canned DNS samples written in VB.Net. What we can do is forward the
request to the product group and start the process of creating them. The
DNS provider is a relatively new and the samples creation has not kept up
with the sample demand.

Sincerely,
Max Vaughn [MS]
Microsoft Developer Support, MCP, MCAD
Windows Managed Technologies


Disclaimer: This posting is provided "AS IS" with no warranties, and
confers no rights. You assume all risk for your use.
 
V

vbnetdev

I am in the process of trying to desigin a interface similar to HELM but
using IIS, Exchange and Active Directory. I would love to see your code at
some point.



Oliver said:
I'm not sure what you're trying to do exactly with your script, but if
you're looking to add an A_record via vb.net, I have successfully
gotten it to work. I'm currently working on a whole class of DNS
management tools to be used in .NET. What is your goal for your
script? Simply to create an A record?

Oliver Melisiotis
CosmoTek.Net .NET Hosting
--> www.cosmotek.net
--> (e-mail address removed)

Will I get charged for this?

Understand the context of these remarks. I still love .NET. My back is
against the wall and this is frustrating.

The reason I ask is that we made a decision as a business to pursue the
road
of .NET development as the future course of where our business would go.
Even my side business I started on this premise.
We sink thousands of dollars into development environemnts, books, tools
all
to make things happen with .NET. Is it a reflection of me as being a poor
developer? I would like not to think so. I woudl like to think that given
time and the ability to research a given problem the answers will be
there.
And I will find them. But the answers are not out there.

But the thing is when I started learning .NET it was a hobby, a toy. If
it
worked great, if it didn't oh well, no big deal. That is no longer the
case.
Today I have deadlines and requirements and I am expected to deliver.
.NET
is no longer considered "not for production use" and if the documentation
or
tools is incomplete this is not a good situation for a "production use"
software or framework.

I know if I were to write code and fail to provide complete documentation
and such my employement here would be very much in doubt.

Anyway let me know if I am going to be charged for this or have to spend
one
of my support incidents. And again forgive my frustration.


--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com



Max L. Vaughn said:
This is looking a bit more detailed than what can be convered in a
newsgroup posting.

I would suggest created a support incident so we can address your
questions
on a more direct level.

To answer your question about the DNS samples in VB.Net. We do not
have
any canned DNS samples written in VB.Net. What we can do is forward
the
request to the product group and start the process of creating them.
The
DNS provider is a relatively new and the samples creation has not kept
up
with the sample demand.

Sincerely,
Max Vaughn [MS]
Microsoft Developer Support, MCP, MCAD
Windows Managed Technologies


Disclaimer: This posting is provided "AS IS" with no warranties, and
confers no rights. You assume all risk for your use.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top