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

    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)