|
|
|
start date: Tue, 07 Aug 2007 10:15:14 -0000,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
P4trykx
|
|
2
Andrew Brook
|
|
3
Kevin Spencer
|
|
4
Aidy
|
|
5
Kevin Spencer
|
|
6
P4trykx
|
|
7
P4trykx
|
|
8
P4trykx
|
|
9
P4trykx
|
C# open file on windows share
Hello
I hace a code that opens a file on a windows share.
\\comp1\folder1\file.txt
Folder1 has full access for Everyone. I can open it from explorer on
my computer (my user isn't on set the server). However when I run this
code
FileStream file = new FileStream(serverFilePath, FileMode.Open);
from asp code as the same user as I do it form explorer I get
IOException saying that the user and password are wrong. Howto
convince C# not to login ?
--
Patryk
Date:Tue, 07 Aug 2007 10:15:14 -0000
Author:
|
Re: C# open file on windows share
does this work?
System.IO.FileStream fs = new
System.IO.FileStream(serverFilePath,System.IO.FileMode.Open,System.IO.FileAccess.Read);
Andrew
"P4trykx" wrote in message
news:1186481714.516361.273550@b79g2000hse.googlegroups.com...
> Hello
>
> I hace a code that opens a file on a windows share.
>
> \\comp1\folder1\file.txt
>
> Folder1 has full access for Everyone. I can open it from explorer on
> my computer (my user isn't on set the server). However when I run this
> code
>
> FileStream file = new FileStream(serverFilePath, FileMode.Open);
>
> from asp code as the same user as I do it form explorer I get
> IOException saying that the user and password are wrong. Howto
> convince C# not to login ?
>
> --
> Patryk
>
Date:Tue, 7 Aug 2007 12:00:03 +0100
Author:
|
Re: C# open file on windows share
Hi Patryk,
All processes run in the context of a logged-in user account. If you want to
open a file on another computer, your application must be running in the
context of a user that has permissions to open files on that machine. You
can do this with Impersonation.
--
HTH,
Kevin Spencer
Microsoft MVP
Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
"P4trykx" wrote in message
news:1186481714.516361.273550@b79g2000hse.googlegroups.com...
> Hello
>
> I hace a code that opens a file on a windows share.
>
> \\comp1\folder1\file.txt
>
> Folder1 has full access for Everyone. I can open it from explorer on
> my computer (my user isn't on set the server). However when I run this
> code
>
> FileStream file = new FileStream(serverFilePath, FileMode.Open);
>
> from asp code as the same user as I do it form explorer I get
> IOException saying that the user and password are wrong. Howto
> convince C# not to login ?
>
> --
> Patryk
>
Date:Tue, 7 Aug 2007 07:35:27 -0400
Author:
|
Re: C# open file on windows share
On 7 Sie, 13:00, "Andrew Brook" wrote:
> does this work?
> System.IO.FileStream fs = new
> System.IO.FileStream(serverFilePath,System.IO.FileMode.Open,System.IO.FileAccess.Read);
no, I get the same Exception
--
Patryk
Date:Tue, 07 Aug 2007 11:39:11 -0000
Author:
|
Re: C# open file on windows share
On 7 Sie, 13:35, "Kevin Spencer" wrote:
> All processes run in the context of a logged-in user account. If you want to
> open a file on another computer, your application must be running in the
> context of a user that has permissions to open files on that machine. You
> can do this with Impersonation.
Ok, so how does the explorer manage to open this file ?
--
Patryk
Date:Tue, 07 Aug 2007 12:04:11 -0000
Author:
|
Re: C# open file on windows share
Explorer is running as the logged on user, your asp.net code is running
under an account local to the machine that has no access rights to any other
machine on the network, so it cannot access files on shares. You can change
the account your anonymous users run as via the iis admin tools and set it
to an account with the appropriate permissions.
"P4trykx" wrote in message
news:1186488251.836031.206220@o61g2000hsh.googlegroups.com...
> On 7 Sie, 13:35, "Kevin Spencer" wrote:
>> All processes run in the context of a logged-in user account. If you want
>> to
>> open a file on another computer, your application must be running in the
>> context of a user that has permissions to open files on that machine. You
>> can do this with Impersonation.
>
> Ok, so how does the explorer manage to open this file ?
>
> --
> Patryk
>
Date:Tue, 7 Aug 2007 14:18:14 +0100
Author:
|
Re: C# open file on windows share
On 7 Sie, 15:18, "Aidy" wrote:
> Explorer is running as the logged on user, your asp.net code is running
> under an account local to the machine that has no access rights to any other
> machine on the network,
But I'm logged as user12 and the same user is in web.config in
impersonate section
<identity impersonate="true" userName="user12" password="somePassowrd"/
>
There is no users12 on the server(comp1) with the files I want to
access. \\comp1\folder1\file.txt
--
Patryk
--
Patryk
Date:Tue, 07 Aug 2007 13:46:00 -0000
Author:
|
Re: C# open file on windows share
Are you logged in to a domain (Active Directory) account?
--
HTH,
Kevin Spencer
Microsoft MVP
Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
"P4trykx" wrote in message
news:1186494360.375792.249750@q75g2000hsh.googlegroups.com...
> On 7 Sie, 15:18, "Aidy" wrote:
>> Explorer is running as the logged on user, your asp.net code is running
>> under an account local to the machine that has no access rights to any
>> other
>> machine on the network,
>
> But I'm logged as user12 and the same user is in web.config in
> impersonate section
>
> <identity impersonate="true" userName="user12" password="somePassowrd"/
>>
>
> There is no users12 on the server(comp1) with the files I want to
> access. \\comp1\folder1\file.txt
>
>
> --
> Patryk
>
>
>
> --
> Patryk
>
>
>
>
Date:Wed, 8 Aug 2007 07:08:51 -0400
Author:
|
Re: C# open file on windows share
On 8 Sie, 13:08, "Kevin Spencer" wrote:
> Are you logged in to a domain (Active Directory) account?
No, I have a local account.However computer on which I have the
share's is a aomain controller.
I suspect that explorer first tries to accesses the share using logged
user ant if this fails (no such user on the remote computer) it
connects using Guest account.
--
Patryk
Date:Wed, 08 Aug 2007 11:47:24 -0000
Author:
|
|
|