Last post Jan 23, 2019 08:20 AM by PatriceSc
Jan 23, 2019 06:43 AM|pathipati|LINK
I was using below code to change password for windows account. This code is working in localhost and not in IIS.
I noticed in IIS, when i changed the DefaultAppPool identity to LocalSystem it is working. But, My app pool identity is ApplicationPoolIdentity. it is not working
Process QProc = new Process();
// Do Something To hide Command(cmd) Window
QProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
QProc.StartInfo.CreateNoWindow = true;
// Call Net.exe
QProc.StartInfo.WorkingDirectory = "C:\\windows\\SYSTEM32";
//QProc.StartInfo.WorkingDirectory = filePath;
QProc.StartInfo.FileName = "net.exe";
QProc.StartInfo.UseShellExecute = false;
QProc.StartInfo.RedirectStandardError = true;
QProc.StartInfo.RedirectStandardInput = true;
QProc.StartInfo.RedirectStandardOutput = true;
// Prepare Command for Exec
QProc.StartInfo.Arguments = @" user " + txtUserName.Text + " " + txtPassword.Text;
Jan 23, 2019 08:20 AM|PatriceSc|LINK
More likely a permission issue. You don't have an exception or error message to confirm that ?
If this is to change the user password I would rather use https://docs.microsoft.com/en-us/dotnet/api/system.directoryservices.accountmanagement.authenticableprincipal.setpassword?redirectedfrom=MSDN&view=netframework-4.7.2#System_DirectoryServices_AccountManagement_AuthenticablePrincipal_SetPassword_System_String_
You can also connect to AD using a dedicated account so that your app doesn't generally have this permission.