WMI路径问题 [英] WMI Path Problem

查看:81
本文介绍了WMI路径问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

此代码可以使用vb.net和

WMI将名称服务器添加到DNS中的容器中。下面的代码如果要添加WWW等主机记录并添加一个MX记录则不会。它注意到无效路径。投诉。任何想法

我做错了什么?这是vb.net 2005,平台是Windows

Server 2003 SP1。


''代码工作原理

Dim classInstance3 As新的ManagementObject(_

" root \MicrosoftDNS",_

" MicrosoftDNS_NSType.ContainerName =''"&

queryObj (ContainerName)&"'',DnsServerName =''"& queryObj(" DnsServerName")

&"'',DomainName =''"& ; queryObj(" DomainName")&"'',OwnerName =''"&

queryObj(" OwnerName")&"'',RecordClass =''" ;& queryObj(" RecordClass")&

"'',RecordData =''"& queryObj(" DnsServerName")&"。''", _

没什么)


Dim inParamsNS2 As ManagementBaseObject = _

classInstance3.GetMethodParameters(" CreateInstance FromPropertyData")


''添加输入参数。

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(" CreateInstanceFromPro pertyData",

inParamsNS2,Nothing)


''无法添加主机记录 - 找不到无效路径或方法。这个

是第一个被添加的主机记录。所有者名称字段让我烦恼。它b / b
似乎是指现有的主机记录,但尚未存在。我试过了
(OwnerName ="& Nothing&"等)。我在这里展示了

的硬编码。谢谢你的帮助。


Dim classInstance作为新的ManagementObject(_

" root \ MysoftoftDNS",_

MicrosoftDNS_AType.ContainerName =''zz.com'',DnsServ erName =''w2k3.JJK.ds。'',DomainName =''zz.com'',OwnerNam e =''zz.com'',RecordClass =''1'',RecordData =''155.155.1.1 43''",

_

什么都没有)


''获取方法的[in]参数

Dim inParams As ManagementBaseObject = _

classInstance.GetMethodParameters(" CreateInstanceF romPropertyData")

>
''添加输入参数。

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(" ; CreateInstanceFromProp ertyData",

inParams,Nothing)


''列出outParams

Console.WriteLine(&out; Out parameters: ")

Console.WriteLine(" RR:{0}",outParams(" RR"))


Catch err As ManagementException


MessageBox.Show("尝试执行时发生错误

WMI方法:" &安培; err.Message)

结束尝试


解决方案


< blockquote class =post_quotes>所有者名称字段让我烦恼。它似乎是指现有的主机记录,但尚不存在。




我认为您需要为所有者名称字段提供有效的服务器名称,

请参考以下technet链接中的示例脚本:

创建名称服务器DNS记录
http://www.microsoft.com/technet/scr...dns / records / nw

revb08.mspx


顺便说一下,如果运行时遇到任何问题,这不是VB.NET问题

上面的示例,我建议你可以在一些网络中咨询这个问题

相关的MSDN新闻组,你会得到更好更快的帮助。


感谢您的理解!


祝你好运,

Gary Chang

Microsoft社区支持

======================================== ========== ====

请注意新闻组SECURE CODE和PASSWORD将于2006年2月14日上午9点在太平洋标准时间上午2点更新。请完成重新注册过程

出现提示时输入安全代码mmpng06。输入

安全代码mmpng06后,您就可以更新个人资料并访问

合作伙伴新闻组。

=== =============================================== === =

在回复帖子时,请回复群组通过你的新闻阅读器

,其他人可以从这个问题中学习并从中受益。

==================== ============================== ====

此帖子提供原样 ;没有保证,也没有授予任何权利。

================================= ================= ====


我不同意。

如果A记录已经存在,例如

" *",则此代码执行得非常好。如果不存在,则会提供无效的方法或路径。


我们不创建名称服务器。我们正在创建

区域的主机记录。


请跟进。谢谢。


-

使用KJM获取功能强大的网络,数据库,应用程序和电子邮件托管

解决方案
http://www.kjmsolutions.com


"" Gary Chang [MSFT]"" <,V - ****** @ online.microsoft.com>在消息中写道

新闻:Wx ************* @ TK2MSFTNGXA01.phx.gbl ...


所有者姓名字段让我烦恼。它似乎是指现有的主机记录,但尚不存在。



我认为您需要为所有者名称字段提供有效的服务器名称,请参阅以下technet链接中的示例脚本:

创建名称服务器DNS记录
http://www.microsoft.com/technet/scr...dns/records/nw
revb08.mspx

顺便说一下,这不是VB.NET的问题,如果你在运行上面有任何问题上面的样品,我建议你可以参考这个问题一些网络相关的MSDN新闻组,你会得到更好,更快的帮助。

感谢您的理解!

致以最诚挚的问候,
< Gary Chang
微软社区支持
================================== ================ ====
请注意新闻组SECURE CODE和PASSWORD将是在太平洋标准时间2006年2月14日上午9点更新。请在提示时输入安全代码mmpng06完成重新注册过程。一旦您输入了
安全代码mmpng06,您就可以更新您的个人资料并访问
合作伙伴新闻组。
=========== ======================================= ====
回复时帖子,请回复群组通过你的新闻阅读器,以便其他人可以从这个问题中学习并从中受益。
============================ ====================== ====
此帖子是原样提供的。没有保证,也没有赋予
权利。
================================= ================= ====



此代码成功创建了主机记录htp ;在abc.com中即使

也没有以前的主机记录。这是通过在select语句中引用另一个

现有域来完成的。然而,最后它报告了

一般错误。没有给出进一步的解释。


请指教....


Dim classInstance作为新的ManagementObject(范围,_



ManagementPath(" MicrosoftDNS_AType.ContainerName =''existingdomain.com'',DnsServerName =''server.DOMAIN.d s'',DomainName =''existingdomain.com'' ,OwnerName =''www。existingdomain.com'',RecordClass =''1'',RecordData =''10 .10.10.10''"),

_

没什么)


''获取方法的参数[/]
Dim inParams As ManagementBaseObject = _

classInstance .GetMethodParameters(" CreateInstanceF romPropertyData")

''添加输入参数。

inParams(" ContainerName")=" abc.com"

inParams(" DnsServerName")=" server.DOMAIN.ds"

inParams(" IPAddress")=" 10.10.10.10"

inParams(" OwnerName&q uot;)=" htp"

inParams(" RecordClass")= 1

inParams(" TTL")= 3600

''执行方法并获取返回值。

Dim outParams As ManagementBaseObject = _

classInstance.InvokeMethod(" CreateInstanceFromProp ertyData",

inParams,Nothing)


''列出outParams

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


关闭()


Catch err As ManagementException


MessageBox.Show("一个错误在尝试执行

WMI方法时发生: &安培; err.Message)


结束尝试


-

获取功能强大的网络,数据库,应用程序和电子邮件托管KJM

解决方案
http://www.kjmsolutions .com


" vbnetdev" < VB ****** @ community.nospam>在消息中写道

新闻:OW ************** @ TK2MSFTNGP09.phx.gbl ...

我不同意。
当A记录已经存在时,例如
" *",此代码执行得非常好。如果不存在,则会提供无效的方法或路径。

我们不创建名称服务器。我们正在为
区创建一个主机记录。

请跟进。谢谢。

-
使用KJM获得功能强大的网络,数据库,应用程序和电子邮件主机
http://www.kjmsolutions.com

"Gary Chang [MSFT]"" <,V - ****** @ online.microsoft.com>在消息中写道
新闻:Wx ************* @ TK2MSFTNGXA01.phx.gbl ...


所有者名称字段让我烦恼。它似乎是指现有的主机记录,但尚不存在。



我认为您需要为所有者名称字段提供有效的服务器名称,请参阅以下technet链接中的示例脚本:

创建名称服务器DNS记录
http://www.microsoft.com/technet/scr...dns/records/nw
revb08.mspx

顺便说一下,这不是VB.NET的问题,如果你在运行上面有任何问题上面的样品,我建议你可以参考这个问题一些网络相关的MSDN新闻组,你会得到更好,更快的帮助。

感谢您的理解!

致以最诚挚的问候,
< Gary Chang
微软社区支持
================================== ================ ====
请注意新闻组SECURE CODE和PASSWORD将是更新于2006年2月14日太平洋标准时间上午9点。请在提示时输入安全代码mmpng06完成重新注册过程。一旦您输入了
安全代码mmpng06,您就可以更新您的个人资料并访问
合作伙伴新闻组。
=========== ======================================= ====
回复时帖子,请回复群组通过你的新闻阅读器,以便其他人可以从这个问题中学习并从中受益。
============================ ====================== ====
此帖子是原样提供的。没有保证,也没有赋予
权利。
================================= ================= ====




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("CreateInstance FromPropertyData")

'' 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("CreateInstanceFromPro pertyData",
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'',DnsServ erName=''w2k3.JJK.ds.'',DomainName=''zz.com'',OwnerNam e=''zz.com'',RecordClass=''1'',RecordData=''155.155.1.1 43''",
_
Nothing)

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

'' 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("CreateInstanceFromProp ertyData",
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


解决方案

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/scr...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.
================================================== ====


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]"" <v-******@online.microsoft.com> wrote in message
news:Wx*************@TK2MSFTNGXA01.phx.gbl...

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/scr...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.
================================================== ====



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.d s'',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("CreateInstanceF romPropertyData")

'' 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("CreateInstanceFromProp ertyData",
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" <vb******@community.nospam> wrote in message
news:OW**************@TK2MSFTNGP09.phx.gbl...

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]"" <v-******@online.microsoft.com> wrote in message
news:Wx*************@TK2MSFTNGXA01.phx.gbl...

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/scr...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.
================================================== ====




这篇关于WMI路径问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆