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 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能