Requiremnet--on click of a button, a site will be created on iis.I am passing a name,that will become the name of the site on iis
I created a powershell script to do this.Using process.start, i want to open a powershell.exe and want to execute my code inside it. Code...
System.Diagnostics.Process proc = new System.Diagnostics.Process();
Char[] chr = Password.ToCharArray();
System.Security.SecureString pwd = new System.Security.SecureString();
foreach (char c in chr)
{
pwd.AppendChar(c);
}
proc.StartInfo.FileName = "powershell.exe";
//proc.StartInfo.Arguments = powershellScriptCode; //It contains powershell script to create a new website in iis
proc.StartInfo.UserName = UserName; //Comes from config file
proc.StartInfo.Password = pwd; //Comes from config file
proc.StartInfo.Domain = Domain; //Comes from config file
proc.StartInfo.RedirectStandardError = true;
开发者_如何学Python proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.UseShellExecute = false;
bool result = proc.Start();
when i run this code in local environment,it run sucessfully and creates a website, but when i run this code on IIS(After hosting), it is not able to create a site on IIS.so what type of permissions i required.
You need to change the identitiy in the Application Pool. Go to IIS Manager -> Application Pools -> Advanced Settings -> Process Model -> Identity. Change it to "Local system" and try again (but remember to change it back unless you know what you are doing, security-wise; if it works, create a user account with just the required permissions).
精彩评论