Jump to content


Photo

UNC Pathnames and Log files on an Intranet


  • Please log in to reply
3 replies to this topic

#1 thepip3r

thepip3r
  • Members
  • PipPipPip
  • Advanced Member
  • 289 posts

Posted 07 June 2006 - 06:52 PM

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:

$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>";
}

and i keep getting: \\server\inventory agent\data\07-06-2006 is not a directory. any ideas?

#2 xyph

xyph
  • Staff Alumni
  • Advanced Member
  • 3,712 posts
  • LocationSurrey, BC

Posted 07 June 2006 - 08:38 PM

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]


Everything you need to know about storing user-names and passwords
http://www.openwall....Users-Passwords
Blank Page? Try forcing errors to display
ini_set('display_errors',1);
error_reporting(-1);

#3 thepip3r

thepip3r
  • Members
  • PipPipPip
  • Advanced Member
  • 289 posts

Posted 07 June 2006 - 10:09 PM

thanx xyph... i'll try those suggestions and let you know what i find.

#4 thepip3r

thepip3r
  • Members
  • PipPipPip
  • Advanced Member
  • 289 posts

Posted 08 June 2006 - 05:47 PM

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...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users