S
Saya
Hi Folks,
I have now spend app. 3 days to get the below scenario to work, but
can not get there!
..Net version = 2.0.50727
Windows version = Microsoft Windows [Version 5.2.3790] = Windows
Server 2003
Now I have to develop a webservice which is run on the server. The
webservice will need to invoke an exe (which is a server application
exe). Now this exe file needs to be exeucuted as an application user,
thus I have the need of starting the process as a application user
through the webservice.
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
// Added
using System.Diagnostics;
using System.Security;
using System.IO;
using System.Configuration;
[WebService(Namespace = "http://intranet.webservices.lundbeck.com/")]
public class TSUsers : System.Web.Services.WebService
{
public TSUsers () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string CreateTSUser(String UserName, String UserEmail)
{
Process p = new Process();
p.StartInfo.UserName =
ConfigurationManager.AppSettings["TSMasterName"];
p.StartInfo.Password = GetSecurePass();
p.StartInfo.Domain = "hlucorp";
//p.StartInfo.LoadUserProfile = true;
p.StartInfo.FileName = @"e:\iw-home\bin\iwuseradm.exe";
p.StartInfo.Arguments = "add-user hluw0447d\\tstest1";
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
try {
p.Start();
p.WaitForExit(1000);
StreamReader srOutput = p.StandardOutput;
StreamReader srError = p.StandardError;
String CmdOutput = srOutput.ReadToEnd();
String CmdError = srError.ReadToEnd();
srError.Close();
srOutput.Close();
return CmdError;
}
catch (Exception ex) {
return ex.Message;
}
}
[WebMethod]
private SecureString GetSecurePass() {
// Different user
SecureString securePass = new SecureString();
String UserPass =
ConfigurationManager.AppSettings["TSMasterPassword"];
foreach (char C in UserPass) {
securePass.AppendChar(C);
}
return securePass;
}
}
Now I can see in the taskmanager that iwuseradm.exe has been started
as the application user, but nothing happens. the whole thing just
hangs!
I have seen a lot of postings on this matter, but not one offered a
solution. Different security issues are discussed etc. but no
solution!
Can anyone help ?
Regards
Saya
I have now spend app. 3 days to get the below scenario to work, but
can not get there!
..Net version = 2.0.50727
Windows version = Microsoft Windows [Version 5.2.3790] = Windows
Server 2003
Now I have to develop a webservice which is run on the server. The
webservice will need to invoke an exe (which is a server application
exe). Now this exe file needs to be exeucuted as an application user,
thus I have the need of starting the process as a application user
through the webservice.
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
// Added
using System.Diagnostics;
using System.Security;
using System.IO;
using System.Configuration;
[WebService(Namespace = "http://intranet.webservices.lundbeck.com/")]
public class TSUsers : System.Web.Services.WebService
{
public TSUsers () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string CreateTSUser(String UserName, String UserEmail)
{
Process p = new Process();
p.StartInfo.UserName =
ConfigurationManager.AppSettings["TSMasterName"];
p.StartInfo.Password = GetSecurePass();
p.StartInfo.Domain = "hlucorp";
//p.StartInfo.LoadUserProfile = true;
p.StartInfo.FileName = @"e:\iw-home\bin\iwuseradm.exe";
p.StartInfo.Arguments = "add-user hluw0447d\\tstest1";
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
try {
p.Start();
p.WaitForExit(1000);
StreamReader srOutput = p.StandardOutput;
StreamReader srError = p.StandardError;
String CmdOutput = srOutput.ReadToEnd();
String CmdError = srError.ReadToEnd();
srError.Close();
srOutput.Close();
return CmdError;
}
catch (Exception ex) {
return ex.Message;
}
}
[WebMethod]
private SecureString GetSecurePass() {
// Different user
SecureString securePass = new SecureString();
String UserPass =
ConfigurationManager.AppSettings["TSMasterPassword"];
foreach (char C in UserPass) {
securePass.AppendChar(C);
}
return securePass;
}
}
Now I can see in the taskmanager that iwuseradm.exe has been started
as the application user, but nothing happens. the whole thing just
hangs!
I have seen a lot of postings on this matter, but not one offered a
solution. Different security issues are discussed etc. but no
solution!
Can anyone help ?
Regards
Saya