Connecting Tech Pros Worldwide Forums | Help | Site Map

using network drive with php

Oklas
Guest
 
Posts: n/a
#1: Jul 17 '05
Hello NG,

first my configuration :

Windows 2003 Server
IIS 6.0
PHP 4.3.6


i want to connect via php to a network drive (e.g.
\\computername\c$\temp\file.txt). Another point is that it is only possible
to connect to the drive with username and password....

Does anyone know how to script something like this? fopen doesn't work...
I've tried it with

fopen("\\USER:PASS@computer\\c\$\\file.txt","r");

but it doesn't work.....

Before writing me to map the network drive and then using the letter....
that's not possible, because the IIS/PHP is working as INET User... And I
don't want the server to be all time logged in as INET User...

I really want/have to connect with the help of php and you :)

Greetings,

cma



Daniel Tryba
Guest
 
Posts: n/a
#2: Jul 17 '05

re: using network drive with php


Oklas <nobody@no-spamming-please.com> wrote:[color=blue]
> i want to connect via php to a network drive (e.g.
> \\computername\c$\temp\file.txt). Another point is that it is only possible
> to connect to the drive with username and password....
>
> Does anyone know how to script something like this? fopen doesn't work...
> I've tried it with
>
> fopen("\\USER:PASS@computer\\c\$\\file.txt","r");
>
> but it doesn't work.....[/color]

Not enough \es... To get a literal \ you need to type \\ in a string
between " quotes.

Don't know if it will work with enough slashes though.

--

Daniel Tryba

Chung Leong
Guest
 
Posts: n/a
#3: Jul 17 '05

re: using network drive with php


"Oklas" <nobody@no-spamming-please.com> wrote in message
news:cffmhv$4h0$1@news.mch.sbs.de...[color=blue]
> Hello NG,
>
> first my configuration :
>
> Windows 2003 Server
> IIS 6.0
> PHP 4.3.6
>
>
> i want to connect via php to a network drive (e.g.
> \\computername\c$\temp\file.txt). Another point is that it is only[/color]
possible[color=blue]
> to connect to the drive with username and password....
>
> Does anyone know how to script something like this? fopen doesn't work...
> I've tried it with
>
> fopen("\\USER:PASS@computer\\c\$\\file.txt","r");
>
> but it doesn't work.....
>
> Before writing me to map the network drive and then using the letter....
> that's not possible, because the IIS/PHP is working as INET User... And I
> don't want the server to be all time logged in as INET User...
>
> I really want/have to connect with the help of php and you :)
>
> Greetings,
>
> cma[/color]

You're trying to do the impossible. If the IIS user has no access, PHP has
no access.


Oklas
Guest
 
Posts: n/a
#4: Jul 17 '05

re: using network drive with php



"Chung Leong" <chernyshevsky@hotmail.com> wrote in message
news:67CdnQF5w79YqYHcRVn-ow@comcast.com...[color=blue]
> "Oklas" <nobody@no-spamming-please.com> wrote in message
> news:cffmhv$4h0$1@news.mch.sbs.de...[color=green]
> > Hello NG,
> >
> > first my configuration :
> >
> > Windows 2003 Server
> > IIS 6.0
> > PHP 4.3.6
> >
> >
> > i want to connect via php to a network drive (e.g.
> > \\computername\c$\temp\file.txt). Another point is that it is only[/color]
> possible[color=green]
> > to connect to the drive with username and password....
> >
> > Does anyone know how to script something like this? fopen doesn't[/color][/color]
work...[color=blue][color=green]
> > I've tried it with
> >
> > fopen("\\USER:PASS@computer\\c\$\\file.txt","r");
> >
> > but it doesn't work.....
> >
> > Before writing me to map the network drive and then using the letter....
> > that's not possible, because the IIS/PHP is working as INET User... And[/color][/color]
I[color=blue][color=green]
> > don't want the server to be all time logged in as INET User...
> >
> > I really want/have to connect with the help of php and you :)
> >
> > Greetings,
> >
> > cma[/color]
>
> You're trying to do the impossible. If the IIS user has no access, PHP has
> no access.
>
>[/color]

Why impossible? When I tell PHP the Account that has got access, then it
should be able to connect. The same in Windows Explorer. You can connect to
a share with another username and password. Your own user doesn't have to be
allowed to connect to the share. So why should this be something else with
IIS and PHP?


Alvaro G Vicario
Guest
 
Posts: n/a
#5: Jul 17 '05

re: using network drive with php


*** Oklas wrote/escribió (Thu, 12 Aug 2004 14:07:26 +0200):[color=blue]
> fopen("\\USER:PASS@computer\\c\$\\file.txt","r");[/color]

Are you sure you can add user and pass to a UNC path? I've been trying it
and it doesn't even work in Windows explorer. The function fopen() accepts
URLs, but yours doesn't look like a valid URL (there's not protocol info).


--
-- Álvaro G. Vicario - Burgos, Spain
-- Questions sent to my mailbox will be billed ;-)
--
Zurab Davitiani
Guest
 
Posts: n/a
#6: Jul 17 '05

re: using network drive with php


Alvaro G Vicario wrote:
[color=blue]
> *** Oklas wrote/escribió (Thu, 12 Aug 2004 14:07:26 +0200):[color=green]
>> fopen("\\USER:PASS@computer\\c\$\\file.txt","r");[/color]
>
> Are you sure you can add user and pass to a UNC path? I've been trying it
> and it doesn't even work in Windows explorer. The function fopen() accepts
> URLs, but yours doesn't look like a valid URL (there's not protocol info).[/color]

Well, fopen does handle SMB paths as it says here:

http://us4.php.net/manual/en/wrappers.php

but I'm not sure it has an SMB client to do an authentication. Maybe there's
some COM object on Windows that OP can use to do this. On Linux and Unix it
seems like (I haven't used this) you can do this by having Samba and
http://www.nivel0.net/SmbWebClient
Chung Leong
Guest
 
Posts: n/a
#7: Jul 17 '05

re: using network drive with php



"Oklas" <nobody@no-spamming-please.com> wrote in message
news:cfhtfi$quo$1@news.mch.sbs.de...[color=blue]
>
> "Chung Leong" <chernyshevsky@hotmail.com> wrote in message
> news:67CdnQF5w79YqYHcRVn-ow@comcast.com...[color=green]
> > "Oklas" <nobody@no-spamming-please.com> wrote in message
> > news:cffmhv$4h0$1@news.mch.sbs.de...[color=darkred]
> > > Hello NG,
> > >
> > > first my configuration :
> > >
> > > Windows 2003 Server
> > > IIS 6.0
> > > PHP 4.3.6
> > >
> > >
> > > i want to connect via php to a network drive (e.g.
> > > \\computername\c$\temp\file.txt). Another point is that it is only[/color]
> > possible[color=darkred]
> > > to connect to the drive with username and password....
> > >
> > > Does anyone know how to script something like this? fopen doesn't[/color][/color]
> work...[color=green][color=darkred]
> > > I've tried it with
> > >
> > > fopen("\\USER:PASS@computer\\c\$\\file.txt","r");
> > >
> > > but it doesn't work.....
> > >
> > > Before writing me to map the network drive and then using the[/color][/color][/color]
letter....[color=blue][color=green][color=darkred]
> > > that's not possible, because the IIS/PHP is working as INET User...[/color][/color][/color]
And[color=blue]
> I[color=green][color=darkred]
> > > don't want the server to be all time logged in as INET User...
> > >
> > > I really want/have to connect with the help of php and you :)
> > >
> > > Greetings,
> > >
> > > cma[/color]
> >
> > You're trying to do the impossible. If the IIS user has no access, PHP[/color][/color]
has[color=blue][color=green]
> > no access.
> >
> >[/color]
>
> Why impossible? When I tell PHP the Account that has got access, then it
> should be able to connect. The same in Windows Explorer. You can connect[/color]
to[color=blue]
> a share with another username and password. Your own user doesn't have to[/color]
be[color=blue]
> allowed to connect to the share. So why should this be something else with
> IIS and PHP?
>[/color]

PHP doesn't know how to do Windows authentication, that's why it's
impossible. You might be able to create a mapped drive with help from one of
the Windows Host Scripting ActiveX control. Although if you're going to do
that you might just as well give the IIS user access.


Closed Thread