System.IO.FileStream of a net Resource

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a application that must read file in a shared folder.

This folder is on a server outside my domain (DMZ server).

Resource's folder path example: \\80.80.80.80\Resources.

I have opened this folder for everyone. And all the ports beetwen my
application server and my resources server are opened.

If I try to read a file in this folder with the
System.IO.FileStream
I have a error of "user unknow or wrong password"

Can I set a user before the System.IO.FileStream call?

If I move this folder on a server in my domain all works.

Can someone help me?
Thank you very mutch.
 
Here is what I get. You are logged in to Domain A and need a resource on
Domain B. Apparently, your account is not trusted by Domain B (or you are
using the anonymous ASP.NET account?). Thus, you cannot pull resources using
a FileStream.

Solutions:
1. Get the account trusted. If this is outside of your DMZ, but still in
your organization, it is possible, as a trust relationship can be maintained.
If it is another company, it is not likely going to happen.

2. Have the person in the other domain set up a service to which you can
pass account information. Web services are the answer (NOTE: by web services,
I mean either ASMX web services or Remoting). This means the pull will have
to be set up on the other side.

3. Have an FTP set up and pull down some FTP client code from a site like
SourceForge.net. This also requires set up on the remote site.

4. Get the account trusted by assigning an account.

You are attempting #4, which may be your only option. Unfortunately, the
FileStream does not have credentials associated with it (nor is there any way
to accomplish this).

My guess is you are going to have to delve down into System.Net and perhaps
System.Net.Sockets to get your work done. I do not have any sample code nor a
particular methodology in mind, but this is where I would start searching, as
you have the ability to set up credentials on the System.Net classes. \

Hope this gets you closer to your solution.


--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
I have tried with this example

http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q306158#4

but I can't log on my DMZ

I tired with
bool result=impersonateValidUser("administrator", "\\80.80.80.80", "admin");
or
bool result=impersonateValidUser("administrator", "\\SERVICE", "admin");
where SERVICE is the name of the server
and more else
but this don't works

If I try to impersonate a user in my domain, that's works!.

thank's for your reply!
 
Boni said:
I have tried with this example

http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q306158#4

but I can't log on my DMZ

I tired with
bool result=impersonateValidUser("administrator", "\\80.80.80.80",
"admin");
or
bool result=impersonateValidUser("administrator", "\\SERVICE", "admin");
where SERVICE is the name of the server
and more else
but this don't works

If I try to impersonate a user in my domain, that's works!.

thank's for your reply!

Ok, you can't impersonate users from arbitrary users on your machine. For
instance FooDomain\Admin has no rights on my box, so I can't impersonate
that user on my box!

There are a couple of options in addition to those Gregory mentioned. One
is Workgroup Authentication, and the other is "NET USE". Here's how they
work.

For Workgroup Authentication you set up local (non-domain) users on both
boxes with the same password, (say "FooUser"). Then you impersonate
"MyBox\FooUser" and connect to the OtherBox. If "OtherBox\FooUser" has the
same password as MyBox\FooUser then you can access resources on OtherBox.
This is probably your best bet.

The other option is "NET USE". This one is really tricky since a user
session can only have one connection to a remote share, and it requires
P\Invoke to use. So on second thought, forget "NET USE".

David
"
 
Back
Top