简体   繁体   English

访问 PHP 中 Windows 域共享驱动器上的文件

[英]Accessing Files on Windows Domain Share Drive in PHP

I have a bunch of documents stored on a separate machine that I need to serve from a PHP/IIS server.我有一堆文档存储在需要从 PHP/IIS 服务器提供的单独机器上。 The catch is that the document drive is on a machine that's attached to an Active Directory domain, and the webserver is not, so I'm unsure where to provide the AD user that PHP needs to authenticate with to access the drive.问题是文档驱动器位于连接到 Active Directory 域的计算机上,而网络服务器不在,所以我不确定在哪里提供 PHP 需要对其进行身份验证才能访问驱动器的 AD 用户。

I have the IIS application pool that calls PHP running as a new Windows user I created (set as the app pool's "Identity", and as the web site's Anonymous Authentication user). I have the IIS application pool that calls PHP running as a new Windows user I created (set as the app pool's "Identity", and as the web site's Anonymous Authentication user). I've logged into the server as this new user and set up a Mapped Network Drive, but after some research I think that's a dead-end;我已经以这个新用户身份登录服务器并设置了映射网络驱动器,但经过一些研究,我认为这是一个死胡同; I read that the service doesn't log into Windows in a way that loads mapped drives.我读到该服务没有以加载映射驱动器的方式登录 Windows。

Referencing just by IP address is closer to working, except I get authenticating errors.仅通过 IP 地址引用更接近工作,除了我得到身份验证错误。 The main solution I'm finding online is to make the app pool run as a user who has access to the drive, but I don't know if that's possible since the server isn't on that Windows domain.我在网上找到的主要解决方案是让应用程序池以有权访问驱动器的用户身份运行,但我不知道这是否可能,因为服务器不在 Windows 域上。 (But I'm also not an AD expert) (但我也不是广告专家)

echo shell_exec('whoami'); //Outputs the name of the Windows user I created

echo scandir('\\\\192.168.1.120\\data$'); //Username/password not found
echo trim(shell_exec('dir \\\\192.168.1.120\\data$ 2>&1')); //Username or password is incorrect

echo scandir('Z:\\'); //Path not found PHP warning
echo trim(shell_exec('dir Z: 2>&1')); //Path not found

If there isn't an easy, non-hacky solution, I can see if the client can put the webserver on the AD domain, but I don't know if that'll have unforeseen side-effects on the other services this server runs.如果没有简单的、非 hacky 的解决方案,我可以查看客户端是否可以将网络服务器放在 AD 域中,但我不知道这是否会对服务器运行的其他服务产生不可预见的副作用.

About whether a Windows web server should be a member of an Active Directory domain?关于 Windows web 服务器是否应该是 Active Directory 域的成员?

If these are public facing and don't require users to be authenticated against the directory, then don't put them in the domain.如果这些是面向公众的,并且不需要用户根据目录进行身份验证,那么不要将它们放在域中。 However, if you need some kind of authentication or looking up information from AD, you might consider running Active Directory Application Mode (ADAM) in the DMZ.但是,如果您需要某种身份验证或从 AD 中查找信息,您可以考虑在 DMZ 中运行 Active Directory 应用程序模式 (ADAM)。 You may need to copy the relevant information from AD to the app partition as ADAM does not synchronize standard AD partitions.您可能需要将相关信息从 AD 复制到应用程序分区,因为 ADAM 不会同步标准 AD 分区。

Of course, If the web server is on the same network as the domain controller, it can be added to the domain to increase manageability.当然,如果 web 服务器与域 controller 在同一网络上,则可以将其添加到域中以增加可管理性。

Use cmdkey as that user to store the AD credentials:使用cmdkey作为该用户来存储 AD 凭据:

cmdkey /add:*.ad.example.com /user:fooapp@ad.example.com /pass:lmao

(Alternatively, create an AD account – or even a local account on the fileserver – that matches the service user's username and password? Since you're accessing the fileserver by IP address, you probably don't care about disabling NTLM or doing things cleanly anyway...) (或者,创建一个与服务用户的用户名和密码匹配的 AD 帐户,甚至是文件服务器上的本地帐户?由于您通过 IP 地址访问文件服务器,您可能不关心禁用 NTLM 或干净地做事反正...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用PHP访问Windows共享 - Accessing a Windows Share using PHP 使用PHP访问Windows上的Windows共享(受限访问) - Accessing a Windows share (restricted access) on Windows using PHP 如何为存储在 Google Drive 中的文件插入权限以与我域中的人共享 - How to insert permissions for files stored in Google Drive to share it with people in my domain 如何读取文件,如果文件或目录在 Windows 共享驱动器(映射驱动器)上可用,使用 php - How to read files ,If files or directory is available on windows shared drive (Mapped drive), using php 通过Linux上的Php计数共享Windows驱动器上的文件 - Counting files on a shared windows drive via Php from Linux PHP 如何使用 IIS10 在网络共享驱动器上创建文件夹和文件 - PHP How to create folder and files on network share drive with IIS10 从Linux服务器上的php访问Windows服务器上的图像文件 - Accessing image files on Windows server from php on Linux server 在网站的服务器端访问Google云端硬盘文件 - Accessing Google Drive Files On The Server Side Of A Website Google Drive:文件上传和访问文件 - Google Drive : File Uploading and Accessing the files 用PHP访问Windows对象? - Accessing Windows Objects with PHP?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM