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

我们正在运行Windows Server 2008的Active Directory。

我们还有一个Linux Ubuntu Server 12.04 with Apache2和LDAP。</ p>

是否可以通过PHP / Javascript访问Windows Server文件系统,并具有当前登录网站的用户的权限?</ p>

背景:我们在Ubuntu服务器上运行Joomla和Mediawiki。 用户编写文章并希望在Windows Server上添加一些文件和文件夹(!)的链接。 恕我直言,除了倾斜链接之外,最好的方法是选择带有PHP / Javascript目录列表的文件/文件夹。 但是用户应该只能看到他有权访问的目录。
由于我需要文件/文件夹的完整路径,因此无法选择HTML-“输入”字段。</ p>

有什么想法?
谢谢你的帮助!</ p>
</ div>

展开原文

原文

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个回答

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

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐