dounao1875 2012-06-12 12:52
浏览 84

使用LDAP / PHP通过Linux访问Windows Server文件

We are running a Active Directory with Windows Server 2008.
We have also a Linux Ubuntu Server 12.04 with Apache2 and LDAP.

Is it possible to access the Windows Server file-system via PHP/Javascript with the permissions of the user who is currently logged in the website?

Background: We are running Joomla and Mediawiki on the Ubuntu Server. A users writes an article and want to add some links to files and folders (!) on the Windows Server. IMHO the best way besides of tipping the link is in selecting the file/folder with a PHP/Javascript directory listing. But the user should only see the directories he has access to.
As I need the full path to the file/folder, an HTML-"input" field is no option.

Any ideas? Thanks for your help!

  • 写回答

1条回答 默认 最新

  • doufu9836 2012-06-12 13:07
    关注

    Unless you can use PHP to authenticate to the Active Directory server (which probably means having the user's password in plaintext), you will need to use PHP to list the files.

    PHP has a scandir() function. Since the PHP would need to be given full read access to the Active Directory server, if you use PHP to ascertain which files the user can see, then you can simply show the ones they need.

    You can get the file structure with this function:

    function listdir($folder) {
        if (!is_dir($folder)) {
            return array(); //empty if not a folder
        }
        $return = scandir($folder);
        $subfolders = array();
        array_shift($return); //first two values are always .. & .
        array_shift($return);
        foreach ($return as $key => $value) {
            if (is_dir($value)) {
                unset($return[$key]);
                $subfolders[$value] = listdir($value); //recursively analyse the subdirectory
            }
        }
        return array_merge(array_values($return), $subfolders);
    }
    

    Please note I haven't tested this, so please tell me if there are issues.

    scandir() function reference

    评论

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮