I am running PHP via IIS and need a script to mkdir() on a network share, meaning I would need PHP to create the folder by running as a service account. Is this possible?
How do I change which Windows user PHP runs as?
131 Views Asked by user1765369 At
2
There are 2 best solutions below
0
YurongDai
On
It is possible with PHP to create folders by running as a service account. You can configure an application pool in IIS to run under a service account that has the necessary permissions to access network shares and create folders:
- Open IIS Manager and select the application pool your PHP application is using.
- Click "Advanced Settings" on the right.
- Under Process Model you can set the Identity property to the desired service account.
- Make sure the service account has the necessary permissions on the network share to create the folder.
Related Questions in PHP
- How to add the dynamic new rows from my registration form in my database?
- Issue in payment form gateway
- How to create a facet for WP gridbuilder that displays both parent and child custom fields?
- Function in anonymous Laravel Blade component
- How to change woocomerce or full wordpress currency with value from USD to AUD
- General questions about creating a custom theme Moodle CMS
- How to add logging to an abstract class in php
- error 500 on IIS FastCGI but no clue despite multiple error loggings activated
- Composer installation fails and reverts ./composer.json and ./composer.lock to original content
- How to isolate PHP apps from each other on a local machine(Windows or Linux)?
- Laravel: Using belongsToMany relationship with MongoDB
- window.location.href redirects but is causing problems on the webpage
- Key provided is shorter than 256 bits, only 64 bits provided
- Laravel's whereBetween method not working with two timestamps
- Implementing UUID as primary key in Laravel intermediate table
Related Questions in IIS
- error 500 on IIS FastCGI but no clue despite multiple error loggings activated
- IIS Rewrite Module exclude bots but allow GoogleBot
- How to deploy angular 17 SSR into IIS
- IIS web site with httpplatformhandler on specific route does not redirect to the nextjs site
- Why is 'EDITBIN /STACK:2097152 w3wp.exe' cmd is giving me an LNK1342 error?
- Primeng Angular styles on subdomain don't work
- Apps migrated from IIS server1 to another IIS server2 stopped communicating with an App on IIS server 1 via SSL (HTTPS)
- How to authenticate with REST API service on IIS using pass-through authentication in Python?
- ASP.NET Core 8 is missing from application pool selection after install
- Azure Application Gateway ByPass
- SSL certificate is installed on iis and website but in browser is unknown
- Redirect to another site but show the original URL in browser
- Problem in hosting React App with react-router-dom on IIS Server
- Django Channels on IIS
- ASP.NET Core/Angular17 application files does not load when published in IIS
Related Questions in PERMISSIONS
- How to request administrator rights?
- Private queues MSMQ lose Everyone permission
- Laravel spatie permission many to through? query
- Cannot access Google Spreadsheet metadata by API
- Why does each service need permissions to access something?
- How can I enable my app to access a specific partition directory for reading and writing without showing popup to user?
- Access denied when using Get-PnPSubWeb
- Running gcloud app deploy and getting PERMISSION_DENIED 'compute.regions.get', despite having Owner and Compute admin permissions
- iBooks folder permissions issue. I had access, now I don't have access. How can I regain access please?
- SolarIs 11 VM configure sftp. After restart ssh, the sshd_config file resets?
- Share folders and files between host and Docker as persistent data
- Provide access to Azure Storage Account for all VMs in resource group
- Grant auto permission dont work since Android 14
- ShouldShowRequestPermissionRational not working properly in Huawei HarmonyOS devices
- MAUI Email.ComposeAsync function call throws FeatureNotSupportedException on Android
Related Questions in MKDIR
- File not found in a created directory
- How can I use an array to create subdirectories using mkdir in bash?
- How can I detect an existing directory in ~/ with stat in C?
- Create a directory when the file with that name exists
- Google App Engine - Node.js - Error: ENOENT
- ErrorException. App\Http\Controllers\UserController@user_change_password
- firebase storage Error: ENOENT: no such file or directory, open video.mp4
- Creating multiple directories with mkdir and character range
- mkdir permission denied inside docker container
- problem creating file file in apache druid
- mkdir error : can not create directory ; file exists gitbash
- Can't use fopen and mkdir in same program
- How can I create a directory on Linux with Python when the base path should include ~/?
- MkDir Variable Failing
- Error: EPERM: operation not permitted, mkdir 'first-app' when create react app in subfolder of D
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
A better solution might be to run a service that the running instance of PHP can communicate with to tell the service to create the directory for you. Changing the user that PHP is running as, changes the permissions that PHP has for doing things on your server/network. I realize that is kind of your goal because you want PHP to be able to do more than it can currently, but that can lead to a whole lot more harm. Let's say, for example, that a malicious person were to find a security hole and manage to get your web server to execute arbitrary code on your server. If PHP has elevated privileges, then the code that is executed can do additional harm to your system that it would not have been capable of with the more limited permissions.
You could do a service/scheduled task to read from the file/database to wait for those directory names to be written and then create the directories or a service that listens on 127.0.0.1:xxxx where xxxx is some random port over 1024 and allow PHP to communicate directly with that service to send requests for directory creation. I would make sure the account that the service/scheduled task runs under does not have more than necessary permissions and I would not allow PHP to supply commands, only new directory names that your service/scheduled task can only do mkdir() with what is supplied by PHP. I would also sanitize the directory names so someone couldn't pass
All of this may be more complicated than you wanted it to be, but the policy of least privilege would make you less vulnerable to attack. If you are not worried about security concerns then you can try changing the application pool identify, as Lex Li suggested.