简体   繁体   English

PHP | Powershell | shell_exec()| 权限不足

[英]PHP | Powershell | shell_exec() | Not enough permissions

I am trying to develop a PHP application which executes a Powershell command via shell_exec(). 我正在尝试开发一个PHP应用程序,该程序通过shell_exec()执行Powershell命令。

However Once the command is executed, it doesn't work because it says it doesn't have permission. 但是,一旦执行了该命令,该命令将失去作用,因为它说它没有权限。 Any ideas what I have to do? 有什么想法我要做什么?

My code: 我的代码:

    $psscriptpath = "C:\inetpub\htdocs\school_panel\scripts\change.ps1";
    $cmdlet = "powershell.exe -executionpolicy remotesigned -File {$psscriptpath} -username {$username} -password {$password} < NUL";
    echo $cmdlet;           
    $output = shell_exec($cmdlet);
    echo $output;

There error message: 出现错误信息:

powershell.exe -executionpolicy remotesigned -File C:\inetpub\htdocs\school_panel\scripts\change.ps1 -username testingacount -password TestingTest321 < NULSet-ADAccountPassword : Access is denied
At C:\inetpub\htdocs\school_panel\scripts\change.ps1:18 char:22
+ Set-ADAccountPassword <<<<  $username -NewPassword $newpwd -Reset
    + CategoryInfo          : PermissionDenied: (testingacount:ADAccount) [Set-ADAccountPassword], UnauthorizedAccessException
    + FullyQualifiedErrorId : Access is denied,Microsoft.ActiveDirectory.Management.Commands.SetADAccountPassword

What I have already tried: 我已经尝试过的:

  • Set execution policy to unrestricted on both versions of powershell 在两个版本的Powershell上都将执行策略设置为不受限制
  • Give full permissions to IUSER for CMD, Powershell, PHP-cgi.exe, PHP.exe and the folder containing the website 为IUSER授予对CMD,Powershell,PHP-cgi.exe,PHP.exe和包含网站的文件夹的完整权限
  • Rearranging and doing variety of changes with code. 使用代码重新排列并进行各种更改。

Allowing a web server / engine to run commands directly in a shell is a bad idea in any way I can think of. 以我能想到的任何方式,允许Web服务器/引擎直接在Shell中运行命令都是一个坏主意。 Allowing said commands to be run with high privileges is an even worse idea. 允许以高特权运行所述命令是一个更糟糕的主意。

Source: http://www.w3.org/Security/faq/wwwsf3.html (check Q3 for details. It refers to unix root user but I guess the system of root startup -> fork to nobody user is shared among multiple webservers on multiple platforms) 来源: http : //www.w3.org/Security/faq/wwwsf3.html (有关详细信息,请参阅Q3。它指的是Unix根用户,但我猜想根启动系统->叉到没人的用户在多个Web服务器之间共享在多个平台上)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM