views:

100

answers:

0

Hi!

I've always suposed that I was facing a permission problem, but I'm not sure now. We are trying to manage our Microsoft DNS Server via ASP.NET in different servers with the "dos" command "dnscmd". How?

It may seem easy with:

System.Diagnostics.Process runner = new System.Diagnostics.Process();
runner.StartInfo.UseShellExecute = false;
runner.StartInfo.RedirectStandardOutput = true;
runner.StartInfo.FileName = @"dnscmd";
runner.StartInfo.Arguments = "XXX.XXX.XXX.XXX /ZoneAdd test.com /Primary";
runner.StartInfo.UserName = "username";
SecureString password = new SecureString();
foreach (char c in "password".ToCharArray()) { password.AppendChar(c); }
runner.StartInfo.Password = password;
runner.StartInfo.WorkingDirectory = @"path";
runner.Start();
string output = runner.StandardOutput.ReadToEnd();
runner.WaitForExit();

The result of this code executed by an WCF Service is a dead process called dnscmd, shown in the task manager with user "username", 596KB and 00 CPU load. It never ends, WCF timeout raises first.

I was wondering if it could be a permission problem even "username" was correctly shown in Windows Server Task Manager. So I decided, just in case, to code LogonUser function from advapi32.dll and kernel32.dll with the intention of beign sure that this code was executed with the appropiate credentials to do the job. Unfortunately bad results :(.

DNS Server and WCF server are in different computers, but this code executed by normal console application works ok.

Please, any help would be very appreciated. Thanks a lot!