Jump to content

Recommended Posts

I have a logon script that parses a bunch of information off of the computers on my network and writes that info to an .ini file in a centralized logging location. I know that PHP can read .ini files using parse_ini_file() or whatever but my question is whether my file repository of .ini files has to be located on the same server or not?

Clarification: Can my PHP page that's stored on my web server, read from files stored on my file server? If so, what functions could I use to accomplish this?

Edit: The file server's share where all of the INI files are stored is set up with Everyone, Full Control and the Security permissions are set up for Authenticated Users with Write access. Both the web server and file server are Windows Server 2003.

Edit2: Have tried this but keep getting my listed error that there was an error opening the directory:

[code]$INIPath        = "\\\\server\\inventory agent\\data\\";
$FolderName        = date("d-m-Y",strtotime("now"));

if (is_dir($INIPath . $FolderName)) {
  if ($dh = opendir($INIPath . $FolderName)) {
    while (($file = readdir($dh)) !== false) {
      echo "file:  $file <br>";
    }
    closedir($dh);
  } else {
    echo "Error Opening Directory:  " . $INIPath . $FolderName . "<br>";
  }
} else {
  echo $INIPath . $FolderName . " is not a valid directory.<br>";
}
[/code]

and i keep getting: \\server\inventory agent\data\07-06-2006 is not a directory. any ideas?
Here are some references from user contributed notes @ php.net

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]If you have problems like "failed to open dir: Invalid argument"
when using IIS and trying to access windows/smb network shares, try
//servername/share/directory
instead of
\\servername\share [/quote]

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]In addition to notes above about IIS & PHP reading network shares, here's one solution that works better for me.

in the management console I created a folder where my "read_dir" script runs. click on properties then select the security tab. here you can set the anonymous account to the standard IUSR_$computername% , BUT.. in this case I chose another account that I set up for reading my shares. (make sure login name and password match the credantials you set on the remote machin ;-))

I use this to read a dir and it's contents into a searchable database. and it works like a charm... [/quote]

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Thought I could help clarify something with accessing network shares on a Windows network (2000 in this case), running PHP 4.3.2 under Apache 2.0.44.

However you are logged into the Windows box, your Apache service must be running under an account which has access to the share. The easiest (and probably least safe) way for me was to change the user for the Apache service to the computer administrator (do this in the service properties, under the "Log On" tab). After restarting Apache, I could access mapped drives by their assigned drive letter ("z:\\") or regular shares by their UNC path ("\\\\shareDrive\\shareDir"). [/quote]

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Re: Accessing network directories on W32

In reply to the previous comments, to enable opendir() to open directories like "\\SOMEHOST\shareddir", with PHP+IIS:

Follow the instructions here: [a href=\"http://support.microsoft.com/default.aspx?scid=kb;en-us;Q189408\" target=\"_blank\"]http://support.microsoft.com/default.aspx?...b;en-us;Q189408[/a]

Check that the file share allows reads to IUSR_[HOSTNAME] user. [/quote]

none of those seem to have worked...

for error trapping, does PHP write to STDERR? If so, how do I see what error is being reported other than the echo statement i have for my else clause?

Edit: Well, it's got to be something having to do with accessing different shares because i copied one of the dirs i want to read from my file server over to my web server and it reads the files just fine.... I couldn't get the IUSR_ local anonymous account to work on my web server so I justtried the EVERYONE group only for testing purposes and it STILL didn't work. When PHP prints out my else clause, I can copy and paste that path into START>>RUN and Windows Explorer opens the share just fine. with everyone full control i don't see how it's still a credentials thing but don't know where to go from here...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.