Hi!
Im trying to add a A record to a domain name in MS DNS with C#, it's done
from a webpage with this code:
ManagementClass rr = new ManagementClass (@"root\Microso ftDNS",
"MicrosoftDNS_R esourceRecord",
new ObjectGetOption s(null,new TimeSpan(100), true));
string _ResellerDomain Name = "mydomain.net." ;
object rrText = "web IN A 123.123.123.123 ";
rr.InvokeMethod ("CreateInstanc eFromTextRepres entation", new
object[] { ".", _ResellerDomain Name, rrText});
The record is added to the domain but I get this error even thou it worked:
System.Manageme nt.ManagementEx ception: Generic failure at
System.Manageme nt.ManagementEx ception.ThrowWi thExtendedInfo( ManagementStatu s
errorCode) at System.Manageme nt.ManagementOb ject.InvokeMeth od(String
methodName, ManagementBaseO bject inParameters, InvokeMethodOpt ions options)
at System.Manageme nt.ManagementOb ject.InvokeMeth od(String methodName,
Object[] args) at WebDNS.DNSClass .AddRecord() in c:\documents and
settings\anders \vswebcache\web admin\dnsclass. cs:line 30
All permissions must be correct thou the domain is added.
Have seen other with this error but no solutions!
Line 30 is the InvokeMethod
What is causing the error and what can I do to solve it?
Regards
Anders Aleborg 24 9701
Forgot to say, the MS DNS is placed on a Windows 2003 Server webedition
Hi Anders,
Sorry for the late response.
For this issue, I think you are running the code in a ASP.NET web
application, right?
Could you please create a console application and run the code to see
whether it has any problem? If there is no exception in console
application, we may isolate the issue to the identity that asp.net web
application running on.
Besides, please also test the following sample code: (it is for console
app, you can change Console.WriteLi ne to response.write for asp.net app)
ManagementClass dnsRRClass = new
ManagementClass (@"\\ServerName Here\root\Micro softDNS",
"MicrosoftDNS_R esourceRecord", null);
ManagementBaseO bject inParams =
dnsRRClass.GetM ethodParameters ("CreateInstanc eFromTextRepres entation");
inParams["DnsServerN ame"] = sServer;
inParams["ContainerN ame"] = sDomainName;
inParams["TextRepresenta tion"] = sTextRepresenta tion;
ManagementBaseO bject outParams =
dnsRRClass.Invo keMethod("Creat eInstanceFromTe xtRepresentatio n", inParams,
null);
Console.WriteLi ne("Executing the method returns {0}",
outParams["ReturnValu e"]);
Thanks very much.
Best regards,
Yanhong Huang
Microsoft Community Support
Get Secure! ¨C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
-http://support.microso ft.com/default.aspx?sc id=/servicedesks/msdn/nospam.as
p&SD=msdn
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi!
Got this error from the consol:
D:\>wmitest
Unhandled Exception: System.Manageme nt.ManagementEx ception: Generic failure
at
System.Manageme nt.ManagementEx ception.ThrowWi thExtendedInfo( ManagementStat
us errorCode)
at System.Manageme nt.ManagementOb ject.InvokeMeth od(String methodName,
Managem
entBaseObject inParameters, InvokeMethodOpt ions options)
at WMITest.Class1. Main(String[] args)
The record was added and is working in the DNS but I still get the error :/
Regards
Anders Aleborg
"Yan-Hong Huang[MSFT]" wrote: Hi Anders,
Sorry for the late response.
For this issue, I think you are running the code in a ASP.NET web application, right?
Could you please create a console application and run the code to see whether it has any problem? If there is no exception in console application, we may isolate the issue to the identity that asp.net web application running on.
Besides, please also test the following sample code: (it is for console app, you can change Console.WriteLi ne to response.write for asp.net app)
ManagementClass dnsRRClass = new ManagementClass (@"\\ServerName Here\root\Micro softDNS", "MicrosoftDNS_R esourceRecord", null); ManagementBaseO bject inParams = dnsRRClass.GetM ethodParameters ("CreateInstanc eFromTextRepres entation"); inParams["DnsServerN ame"] = sServer; inParams["ContainerN ame"] = sDomainName; inParams["TextRepresenta tion"] = sTextRepresenta tion; ManagementBaseO bject outParams = dnsRRClass.Invo keMethod("Creat eInstanceFromTe xtRepresentatio n", inParams, null); Console.WriteLi ne("Executing the method returns {0}", outParams["ReturnValu e"]);
Thanks very much.
Best regards, Yanhong Huang Microsoft Community Support
Get Secure! ¨C www.microsoft.com/security Register to Access MSDN Managed Newsgroups! -http://support.microso ft.com/default.aspx?sc id=/servicedesks/msdn/nospam.as p&SD=msdn
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Anders,
Then that seems not related to ASP.NET security.
Have you tested the code that I pasted before? What is the return value
from the last line? Thanks very much for your update. :)
Best regards,
Yanhong Huang
Microsoft Community Support
Get Secure! ¨C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
-http://support.microso ft.com/default.aspx?sc id=/servicedesks/msdn/nospam.as
p&SD=msdn
This posting is provided "AS IS" with no warranties, and confers no rights.
By the way, if it still returns error, could you please paste you .cs file
here? I will test it on my side and contact our supporting team to look
into it.
Thanks.
Best regards,
Yanhong Huang
Microsoft Community Support
Get Secure! ¨C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
-http://support.microso ft.com/default.aspx?sc id=/servicedesks/msdn/nospam.as
p&SD=msdn
This posting is provided "AS IS" with no warranties, and confers no rights.
It givs the error I posted!
using System;
using System.Manageme nt;
namespace WMITest
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
ManagementClass dnsRRClass = new
ManagementClass (@"\\"+ System.Environm ent.MachineName
+@"\root\Micros oftDNS",
"MicrosoftDNS_R esourceRecord", null);
ManagementBaseO bject inParams =
dnsRRClass.GetM ethodParameters ("CreateInstanc eFromTextRepres entation");
inParams["DnsServerN ame"] = ".";
inParams["ContainerN ame"] = "domain.net ";
inParams["TextRepresenta tion"] = "test IN A 123.123.123.123 ";
ManagementBaseO bject outParams =
dnsRRClass.Invo keMethod("Creat eInstanceFromTe xtRepresentatio n", inParams,
null);
Console.WriteLi ne("Executing the method returns {0}",
outParams["ReturnValu e"]);
}
}
}
"Yan-Hong Huang[MSFT]" wrote: By the way, if it still returns error, could you please paste you .cs file here? I will test it on my side and contact our supporting team to look into it.
Thanks.
Best regards, Yanhong Huang Microsoft Community Support
Get Secure! ¨C www.microsoft.com/security Register to Access MSDN Managed Newsgroups! -http://support.microso ft.com/default.aspx?sc id=/servicedesks/msdn/nospam.as p&SD=msdn
This posting is provided "AS IS" with no warranties, and confers no rights.
Have tried with this code as well, the record is created but it gives me a
generic failure message.
public string AddRecord(strin g domainname, string host, string
recordtype,int MXPrio, string target)
{
try
{
ManagementClass dnsRRClass = new ManagementClass (@"\\"+
System.Environm ent.MachineName +@"\root\Micros oftDNS",
"MicrosoftDNS_" +recordtype+"Ty pe", null);
ManagementBaseO bject inParams =
dnsRRClass.GetM ethodParameters ("CreateInstanc eFromPropertyDa ta");
inParams["DnsServerN ame"] = ".";
inParams["ContainerN ame"] = domainname;
inParams["OwnerName"] = host;
if(recordtype== "A")
inParams["IPAddress"] = target;
if(recordtype== "CNAME")
inParams["PrimaryNam e"] = target;
if(recordtype== "NS")
inParams["NSHost"] = target;
if(recordtype== "MX")
{
inParams["Preference "] = MXPrio;
inParams["MailExchan ge"] = target;
}
dnsRRClass.Invo keMethod("Creat eInstanceFromPr opertyData", inParams,
null);
return "ok";
}
catch(Exception ex)
{
return ex.ToString()+" <br><br>"+ex.St ackTrace.ToStri ng();
}
}
"Yan-Hong Huang[MSFT]" wrote: By the way, if it still returns error, could you please paste you .cs file here? I will test it on my side and contact our supporting team to look into it.
Thanks.
Best regards, Yanhong Huang Microsoft Community Support
Get Secure! ¨C www.microsoft.com/security Register to Access MSDN Managed Newsgroups! -http://support.microso ft.com/default.aspx?sc id=/servicedesks/msdn/nospam.as p&SD=msdn
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Anders,
Thanks very much for the detailed update.
I am contacting our support team on it and will reply here as soon as
possible. If you have any more concerns on it, please feel free to post
here.
Best regards,
Yanhong Huang
Microsoft Community Support
Get Secure! ¨C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
-http://support.microso ft.com/default.aspx?sc id=/servicedesks/msdn/nospam.as
p&SD=msdn
This posting is provided "AS IS" with no warranties, and confers no rights.
Yes, I have one more problem, when I try to delete a zone or a record it
takes time, about 40-60 seconds to delete a zone!!! And the CPU goes up to
100% on the server. It can't be normal.
The code:
Delete("Microso ftDNS_Zone", "ContainerName" , "domain.com ")
protected bool Delete(string sTableName, string sFieldName, string
sFieldValue)
{
try
{
string sQuery = String.Format(" SELECT * FROM {0} WHERE {1} = '{2}'",
sTableName, sFieldName, sFieldValue);
ManagementScope m_oScope;
m_oScope = new ManagementScope (new ManagementPath( @"\\" +
System.Environm ent.MachineName + @"\root\Microso ftDNS"));
m_oScope.Connec t();
ManagementObjec tSearcher oSearcher = new
ManagementObjec tSearcher(m_oSc ope, new ObjectQuery(sQu ery));
ManagementObjec tCollection oCollection = oSearcher.Get() ;
foreach (ManagementObje ct oObject in oCollection)
{
oObject.Delete( );
}
return true;
}
catch
{
return false;
}
}
Regards
Anders Aleborg
"Yan-Hong Huang[MSFT]" wrote: Hi Anders,
Thanks very much for the detailed update.
I am contacting our support team on it and will reply here as soon as possible. If you have any more concerns on it, please feel free to post here.
Best regards, Yanhong Huang Microsoft Community Support
Get Secure! ¨C www.microsoft.com/security Register to Access MSDN Managed Newsgroups! -http://support.microso ft.com/default.aspx?sc id=/servicedesks/msdn/nospam.as p&SD=msdn
This posting is provided "AS IS" with no warranties, and confers no rights.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Prasana |
last post by:
Hi EveryBody,
I have one Problem When I am Creating the DNS Zone Using Resource Record
using System Management. Iam Getting an Error Called "Generic Error". Iam
Able to Create a Primary Zone File Using CreateZone Class. But How to create
other files like SOA, MX, Reverse look Up & other files. Iam working on Win
2000 M/c.Kindly Help.
--
Regards,
Prasana Srinivasan
Software Engineer
|
by: a_man |
last post by:
Hi everyone
Im writing an application in c# and I want to print directly to a
printer with some printer specific commands than only the printer
understands. Below is my code.
I have an arraylist with strings that are the commands to be executed.
This arraylist is passed to a function called sendStringToPrinter with
a printername:
ArrayList al= new ArrayList();
String s="! 0 100 290 1"; these are the printer language
al.Add(s);
|
by: Metaman |
last post by:
I'm trying to write a generic method to generate Hashcodes but am having some
problems with (generic) collections. Here is the code of my method:
public static int GetHashCode(object input)
{
try
{
Type objectType = input.GetType();
PropertyInfo properties = objectType.GetProperties();
|
by: Marty Cruise |
last post by:
I successfully deploy my application to 20 domain users. Only one new user
is giving me a problem, although he can access all domain resources.
When he clicks the installation link on the publish page, Framework 2.0
installs successfully, but then the application installation fails during the
"Verifying Application Requirements" process. Can anyone help me figure out
how to solve this? Error is as follows.
PLATFORM VERSION INFO...
|
by: Johan Tibell |
last post by:
I've written a piece of code that uses sockets a lot (I know that
sockets aren't portable C, this is not a question about sockets per
se). Much of my code ended up looking like this:
if (function(socket, args) == -1) {
perror("function");
exit(EXIT_FAILURE);
}
I feel that the ifs destroy the readability of my code. Would it be
| |
by: mps |
last post by:
I want to define a class that has a generic parameter that is itself a
generic class. For example, if I have a generic IQueue<Tinterface, and
class A wants to make use of a generic class that implements IQueue<Tfor
all types T (so it can make use of queues of various object types
internally). As useful as this is, it doesn't seem possible. The natural (but
illegal) notation would be something like
class A<QueueClasswhere QueueClass :...
|
by: sachinrohamare |
last post by:
I am getting following error while iterating through the ManagementObjectCollection:
This error is coming only for the first time. From the 2nd run onwards the code is executed successfully. Surprisingly when I execute the code with the gap of 20-25 minutes the error is reproducible!
Please provide the solution urgently.
Thanks in Advance !
Please check the error details, sample C# code I am using.
Regards,
|
by: =?Utf-8?B?RG9uYWxkIFhpZQ==?= |
last post by:
In C# 2, this works just fine:
public class foo : IEnumerable<string>
{
private string _list;
public IEnumerator<stringGetEnumerator()
{
foreach (string s in _list)
yield return s;
}
|
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= |
last post by:
Hi,
I have written a generic method which does different things depending on
the type of the parameter. I got it to work, but it seems really inelegant.
Is there a better way to do this?
In the code below, ColumnMap is a simple struct which basically has three
properties, Header (a string), Index (an int), TypeOfData (which is a
DataType which is a local eNum). _Mapping is a local List<ColumnMap>.
public ColumnMap GetMap<T>(T value)
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |