I have 2 servers here....SERVER M (hosting the script) and SERVER S (where I want to create new folder).

I want to create a folder on a SERVER S by running the following script that's hosted on SERVER M. Folder home$ already exists in SERVER S, hence it only needs to create a PPan folder.

if (mkdir('\\s/home$/PPan',0777))
{
echo ("made directory");

}
else
{
echo ("cannot make directory");
}

However, if I run the script from my PC (which is not the SERVER M), it doesn't work. But if I login as me on SERVER M and run the script there, it works fine.

If I make a copy of the script and host it locally on my localhost, running the same script, it works - it creates PPan folder on server S. I know it's a security issue but I don't know what it is.

I've also tried below but same result:

$folderPath = '\\sal/home$/PPan';
$oldumask = umask(0) ;
mkdir( $folderPath, 0777 ) ;
umask( $oldumask ) ;

Could anyone nice people help me please?:queasy:

    When PHP scripts are executed by the webserver as the result of a HTTP request, in most installations they are executed under the web server user account, not the account of the person who created/owns the script. Therefore, for the script to create a new directory, the target directory where it is to be created must have read, write, and execute permission for that web server user. This typically means 0777 permission on UNIX/Linux systems (or 0775 if the owner and the web server user share a common group).

      Thank you. I'm not very strong in the web security side...

      I've added SERVERM\IUSR_SERVERM with suggested rights to the php file and added SERVERS\IUSR_SERVERS with suggested rights to the folder that I wish to create subfolder. Still the same old problem!

      For some reason, it seems that if I run the script on serverM, it won't create the subfolder on server S either! Only in serverM itself!

      "HELP! I need sombody!!!"

        You might want to enable all error reporting to see if it tells you anything useful. Add the following before your code:

        ini_set('display_errors', 1);
        error_reporting(E_ALL | E_STRICT);
        

          warning message: "permission dennied"!

          I've even tried granting everyone the full control in the Security tab, and Internet Guest Account (ServerS\IUSR_ServerS) all permission except full control. Still no joy.

          Umm, I am starting to suspect if I would need to assign ServerM\IUSR_ServerM (where the script is hosted)the permission instead of ServerS\IUSR_ServerS? But then, because ServerM\IUSR_ServerM is only a built-in user in ServerM, hence it cannot be seen outside. Do I need to create a user on Active Directory? e.g. ServerM\IUSr_serverM and disable this built-in user in ServerM? But then how do I tell my web server on ServerM to run as IUSR_ServerM?

            Is this a Windows server? Unfortunately, my sysadmin skills - such as they are - are pretty much limited to UNIX-type systems. 🙁

              I dont know if this will work or not but it might be worth trying 0700 instead of 0777

                still no joy with 0700. I think it's the same permission problem as my cacls.exe thread.

                Does mkdir let you create directory across network? Below is my "test results".... Anyone has any idea? This permission thing is driving me nut!

                Running script / Script hosted / Performing task / Performing task loc / Results

                My local PC / Svr_M / creating a directory / Svr_S / Permission denied

                My local PC / Svr_M / creating a directory / Svr_M / OK – directory created

                My local PC / My local PC / creating a directory / Svr_S / OK – directory created

                  Write a Reply...