On remote windows I am executing some commands in php, I need to validate windows credentials before actually execute commands. If credentials are invalid system should display error message without attempting to execute command.
Currently I am validating credentials like this
$check=shell_exec("wmic /NODE:\"$ip\" /USER:\"$id\" /password:\"$passwords\" os get caption,CSDVersion 2>&1 ");
if(strpos($check, 'denied') != false){return "Invalid_credentials";}
It is fulfilling my needs but I need a better way. Kindly help.
Note: I can't use ldap because it is not implemented.