Home All Groups Group Topic Archive Search About

Remote DNS Zone Creation with WMI and VB.NET

Author
21 Feb 2006 11:18 PM
vbnetdev
Hello All:

This is crossposted to 2 WMI groups as they subject matter is relevant to
their focus. I apologize in advance if it offends anyone.

This code is giving access denied errors ("Access is denied. (Exception from
HRESULT: 0x80070005 (E_ACCESSDENIED))") when attempted to be done from a
remote IP. It works if performed locally. Please advise what permissions
must be changed to allow it to work remotely. IN addition, any attempt to
set the IP address in the parameters fails with a cast error. I am assuming
it is because the IP address property is some sort of collection. I have had
to leave it at 'Nothing' in order to create a zone locally. Then I have to
modify the SOA. If there is a way to set it correctly intiailly that would
be desirable.

Also, where are the other properties? AllowUpdates, Aging and such? I see
the ability to query them in Microsoft_DNS Zone but no methods to set them.

Thank You.

Function TryToWork() As Boolean
        Dim connection As New ConnectionOptions
        connection.Username = "Username"
        connection.Password = "PASSWORD"
        connection.Authority = "ntlmdomain:DOMAIN"
        ' connection.Impersonation = ImpersonationLevel.Impersonate
        'connection.EnablePrivileges = True

        Dim scope As New ManagementScope( _
            "\\" & IPAddress & "\root\MicrosoftDNS", connection)

        scope.Connect()

            Dim classInstance3 As New ManagementClass( _
                CStr(scope.Path.ToString), _
                   "MicrosoftDNS_Zone", Nothing)

            'fails at inParams decaration with access denied error

            Dim inParams As ManagementBaseObject = _
                classInstance3.GetMethodParameters("CreateZone")
            inParams("ZoneName") = ZoneName
            inParams("ZoneType") = 0
            inParams("DsIntegrated") = True
            inParams("DataFileName") = Nothing
            inParams("IpAddr") = Nothing
            inParams("AdminEmailName") = AdminEmail

            Dim outParams As ManagementBaseObject = _
                classInstance3.InvokeMethod("CreateZone", inParams, Nothing)

            End Function

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

Author
22 Feb 2006 5:58 AM
Gary Chang[MSFT]
Hi,

We will follow this issue in the microsoft.public.win32.programmer.wmi
newsgroup. If you have any more concerns on it, please check it 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.
======================================================
Author
18 Mar 2006 2:47 AM
Scott
Is the user running the script in the DNS Admin group?


Show quoteHide quote
"vbnetdev" <vbnetdev@community.nospam> wrote in message
news:uLVTv0zNGHA.2816@TK2MSFTNGP15.phx.gbl...
> Hello All:
>
> This is crossposted to 2 WMI groups as they subject matter is relevant to
> their focus. I apologize in advance if it offends anyone.
>
> This code is giving access denied errors ("Access is denied. (Exception
> from HRESULT: 0x80070005 (E_ACCESSDENIED))") when attempted to be done
> from a remote IP. It works if performed locally. Please advise what
> permissions must be changed to allow it to work remotely. IN addition, any
> attempt to set the IP address in the parameters fails with a cast error. I
> am assuming it is because the IP address property is some sort of
> collection. I have had to leave it at 'Nothing' in order to create a zone
> locally. Then I have to modify the SOA. If there is a way to set it
> correctly intiailly that would be desirable.
>
> Also, where are the other properties? AllowUpdates, Aging and such? I see
> the ability to query them in Microsoft_DNS Zone but no methods to set
> them.
>
> Thank You.
>
> Function TryToWork() As Boolean
>        Dim connection As New ConnectionOptions
>        connection.Username = "Username"
>        connection.Password = "PASSWORD"
>        connection.Authority = "ntlmdomain:DOMAIN"
>        ' connection.Impersonation = ImpersonationLevel.Impersonate
>        'connection.EnablePrivileges = True
>
>        Dim scope As New ManagementScope( _
>            "\\" & IPAddress & "\root\MicrosoftDNS", connection)
>
>        scope.Connect()
>
>            Dim classInstance3 As New ManagementClass( _
>                CStr(scope.Path.ToString), _
>                   "MicrosoftDNS_Zone", Nothing)
>
>            'fails at inParams decaration with access denied error
>
>            Dim inParams As ManagementBaseObject = _
>                classInstance3.GetMethodParameters("CreateZone")
>            inParams("ZoneName") = ZoneName
>            inParams("ZoneType") = 0
>            inParams("DsIntegrated") = True
>            inParams("DataFileName") = Nothing
>            inParams("IpAddr") = Nothing
>            inParams("AdminEmailName") = AdminEmail
>
>            Dim outParams As ManagementBaseObject = _
>                classInstance3.InvokeMethod("CreateZone", inParams,
> Nothing)
>
>            End Function
>
> --
> Get a powerful web, database, application, and email hosting with KJM
> Solutions
> http://www.kjmsolutions.com
>
>
>
>