簡體   English   中英

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

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

我正在嘗試開發一個PHP應用程序,該程序通過shell_exec()執行Powershell命令。

但是,一旦執行了該命令,該命令將失去作用,因為它說它沒有權限。 有什么想法我要做什么?

我的代碼:

    $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;

出現錯誤信息:

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

我已經嘗試過的:

  • 在兩個版本的Powershell上都將執行策略設置為不受限制
  • 為IUSER授予對CMD,Powershell,PHP-cgi.exe,PHP.exe和包含網站的文件夾的完整權限
  • 使用代碼重新排列並進行各種更改。

以我能想到的任何方式,允許Web服務器/引擎直接在Shell中運行命令都是一個壞主意。 允許以高特權運行所述命令是一個更糟糕的主意。

來源: 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