Thanks for taking your time to read about my problem, so lets get straight into it.
My ultimate (end) goal is to be able to have a web base PHP app which lets users modify active directory for users inside a network.
I have found out commands that need to be ran via Powershell to change user passwords inside an active directory.
Now here is my current setup:
- There is one main server where IIS is installed and the web application sits at.
- There will be several computers connected to the network which navigate to the website and execute these commands
I have tried adding the code:
$query = shell_exec('Import-Module ActiveDirectory');
$query = shell_exec('$newpwd = ConvertTo-SecureString -String "'.$safe_password.'" -AsPlainText –Force');
$query = shell_exec('Set-ADAccountPassword "'.$safe_username.'" -NewPassword $newpwd –Reset');
Now here are my questions:
1) Once a computer runs that page and has those commands executed, are the commands going to be executed in the main server? where powershell is installed and permissions are granted. If not, my whole app wont work, are there any other solutions?
2) those commands are all powershell commands not cmd.exe commands. So does shell_exec() even run those commands in powershell, or just in cmd.exe. If it only runs in cmd then this wont work, how can i make it run via powershell?
I would appreciate if you could answer and help me out here, thanks alot.