Can do PHP “write” or “copy” on mounted remote share, but not an “unlink” or “rename” (“Access is denied”)

╄→尐↘猪︶ㄣ 提交于 2019-12-13 07:35:49

问题


I guess I need a better understanding of WHY this is not working:

I have an existing PHP script where I use the "exec" command to issue a "net use", passing in a service username and password, so as to mount a UNC file share on our internal network here to a drive letter.

The script, historically, has been used only to then read the files in a couple key directories that we want to look at on that share. I added the ability to create new, empty files successfully (via "fopen") last week.

But now I need to be able to delete, or rename those files via PHP script. (But I haven't tried saving new information into them yet.)

Anytime I try the PHP "unlink" or "rename" command, I get the error: "Access is denied"

I thought perhaps the service account that has mounted the drive was at fault, because if I look at the ownership on the files that it has created, it says the service user owns them.

So, I changed that account to being my own. I KNOW I have full permission on any files in the key directory that I'm testing. However, that didn't change anything.

I found some references here to do a "whoami" command from the script. Well, I did that, one line before attempting an "unlink", and it says it's the IIS user.

So, I'm not sure if it really IS the IIS user that's attempting the "unlink"...and if so, then why did the file get created as the service user and not the IIS user? Or is something else going on here?

I don't have Admin rights on the server where these files exist, so I can't go over there and fiddle with users and permissions or even look at logs... otherwise, I'd be doing that next.

I guess I'm just stymied by the fact that...whatever user is being used... it can create a file, but it can't delete it or rename it? Seems like WRITE permission is the key requirement for all of that.

Any thoughts?

来源:https://stackoverflow.com/questions/44398834/can-do-php-write-or-copy-on-mounted-remote-share-but-not-an-unlink-or-re

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!