Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7723537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:28:03+00:00 2026-06-01T04:28:03+00:00

I’m using php 5.2 with IIS7.5. I have a network share on a NAS

  • 0

I’m using php 5.2 with IIS7.5.

I have a network share on a NAS that is username and password protected. I cannot disable or change authentication info on the NAS. I need to be able to access that network share via php.

I’ve done the following:

Created new user in windows whose username and password matches those on the NAS.
Created IIS application pool that uses this same auth info.
Created a web.config file inside of the php app directory with an impersonation turned on, using the same auth info.

identity impersonate=”true” password=”ThePass” userName=”TheUser” />

Turned on ASP.NET impersonation in the application authentication in IIS.

None of this seemed to work with this simple line of code in php:

$dir = opendir(“\\someservername\somesharename”);
Warning: opendir(\someservername\somesharename) [function.opendir]: failed to open dir: No error in C:\websites\site\forum\testing.php on line 7

So, I decided to test the configuration with ASP.NET.

string[] diretories = System.IO.Directory.GetDirectories(“\\someservername\somesharename”);
The asp.net test worked perfectly.

Going further down the rabbit hole, I ran phpinfo() and checked the username info in it. Down in the “Environment” section of phpinfo, I found the “USERNAME” item. Its value was “TheUser,” as was what I expected.

Everything points to the system being configured correctly until I tried:

echo get_current_user();
Which returned, “IUSR.” That surely isn’t what I expected.

So, how in the world do I get php + IIS7.5 to read from a foreign network share?

Update:

Thanks to a few of the answers, I’ve added

$result = shell_exec("net use o: \\\\pathToServer\\27301  /persistent:yes 2>&1");

Which returns a success. I’m still getting the error on opendir. I tried another test and used is_dir. This returned false on my newly created mapped drive.

var_dump(is_dir("o:\\"));

// Prints: bool(false) 

UPDATE

I ran the script from the command line when logged in as the user that created. The scripts executes correctly. Could this take us back to get_current_user() which returns IUSR? I tryied getmypid() which returned a process ID. I cross referred that process id with the task manager and found that it was for php-cgi.exe, running under the custom user account that I made.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:28:05+00:00Added an answer on June 1, 2026 at 4:28 am

    You can try a test by mapping it like

    $command = "net use $drive \"\\\\$ip\\$share\" $smb_password /user:$domain\\$smb_username";
    $result = shell_exec($command);
    

    on opendir you need to have \\\\$server_name\\$share try with 4 ‘\’ and if mapping like that works and 4 ‘\’ is failing on opendir. You may have credentials not matching.

    If you map it this way new user you created in windows whose username and password matches those on the NAS will have rights on mapped drive that way you do not need to worry about the scope.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I have thousands of HTML files to process using Groovy/Java and I need to
I'm trying to create an if statement in PHP that prevents a single post
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.