473,395 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Accessing files & folders on client/other machine

I have built a web service whose purpose is to copy files from a secure place
to client machine and vice versa. The problem I am having is perhaps related
to permissions and access rights.
For testing purposes, the secure place is setup on the client machine.
The client (window app) calls the web service (on a different machine) and
connects successfully to the web service. However, when client calls a method
that copies the file from secure place to client machine (or vice versa), an
UnauthorizedAccessException is thrown.
In web.config file, authentication mode = “windows”, identity
impersonate=”true”. The secure place folder and the target folder for copy
operation on client machine are publicly shared and have explicitly given
permission to aspnet_wp account. I even allowed Anonymous Logon to Read&
Execute, List Folder Contents and Read. Nothing seems to solve the problem.
The problem occurs when I try to verify the existence of the file (on client
machine) like this:
Dim fiVault FileInfo = New FileInfo(sVaultFileName)
If fiVault.Exists
…..
End If
The Exists always returns false (no exception is thrown). I added some test
code here at this point to open and read the file. That caused it to throw an
exception of type UnauthorizedAccessException.
What am I doing wrong? Is there a better way to accomplish this task? Any
help will be highly appreciated.
TIA
Khalique
(By the way I have tested the web service by logging on to web server and
using IE to call the web service. That works perfectly fine)
Nov 23 '05 #1
4 3725
By default IE passes the credentials with the request, which is not the
default in the client app, so IE works and the app does not. You must set
the credentials explicitly in the client app, either using the credentials
the user is logged on as, or you can set it to someone else, the latter the
user types it in for example. The 2 calls look something like this:
myWebService.Credentials = System.Net.CredentialCache.DefaultCredentials
myWebService.Credentials = new System.Net.NetworkCredential(...)
Check out the Credentials property of the web service in the documentation.

"Khalique" <Kh******@discussions.microsoft.com> wrote in message
news:44**********************************@microsof t.com...
I have built a web service whose purpose is to copy files from a secure
place
to client machine and vice versa. The problem I am having is perhaps
related
to permissions and access rights.
For testing purposes, the secure place is setup on the client machine.
The client (window app) calls the web service (on a different machine) and
connects successfully to the web service. However, when client calls a
method
that copies the file from secure place to client machine (or vice versa),
an
UnauthorizedAccessException is thrown.
In web.config file, authentication mode = "windows", identity
impersonate="true". The secure place folder and the target folder for copy
operation on client machine are publicly shared and have explicitly given
permission to aspnet_wp account. I even allowed Anonymous Logon to Read&
Execute, List Folder Contents and Read. Nothing seems to solve the
problem.
The problem occurs when I try to verify the existence of the file (on
client
machine) like this:
Dim fiVault FileInfo = New FileInfo(sVaultFileName)
If fiVault.Exists
...
End If
The Exists always returns false (no exception is thrown). I added some
test
code here at this point to open and read the file. That caused it to throw
an
exception of type UnauthorizedAccessException.
What am I doing wrong? Is there a better way to accomplish this task? Any
help will be highly appreciated.
TIA
Khalique
(By the way I have tested the web service by logging on to web server and
using IE to call the web service. That works perfectly fine)

Nov 23 '05 #2
Thanks Chris,
I am setting the credentials before calling the web method. And, inside the
web method I have checked that it is set properly.
The problem is that Web Service needs to accesss a file on client machine.
And when it does, it does not impersonate the user. However, it does
impersonate when accessing resources on the Web Server because I am able to
connect and query the SQL Server that is running on the Web Server.
While in Web Method, can we somehow change the credentials? Will that work
in this situation? I mean accessing ressources on client/othermachine?
Khalique
"Chris Botha" wrote:
By default IE passes the credentials with the request, which is not the
default in the client app, so IE works and the app does not. You must set
the credentials explicitly in the client app, either using the credentials
the user is logged on as, or you can set it to someone else, the latter the
user types it in for example. The 2 calls look something like this:
myWebService.Credentials = System.Net.CredentialCache.DefaultCredentials
myWebService.Credentials = new System.Net.NetworkCredential(...)
Check out the Credentials property of the web service in the documentation.

"Khalique" <Kh******@discussions.microsoft.com> wrote in message
news:44**********************************@microsof t.com...
I have built a web service whose purpose is to copy files from a secure
place
to client machine and vice versa. The problem I am having is perhaps
related
to permissions and access rights.
For testing purposes, the secure place is setup on the client machine.
The client (window app) calls the web service (on a different machine) and
connects successfully to the web service. However, when client calls a
method
that copies the file from secure place to client machine (or vice versa),
an
UnauthorizedAccessException is thrown.
In web.config file, authentication mode = "windows", identity
impersonate="true". The secure place folder and the target folder for copy
operation on client machine are publicly shared and have explicitly given
permission to aspnet_wp account. I even allowed Anonymous Logon to Read&
Execute, List Folder Contents and Read. Nothing seems to solve the
problem.
The problem occurs when I try to verify the existence of the file (on
client
machine) like this:
Dim fiVault FileInfo = New FileInfo(sVaultFileName)
If fiVault.Exists
...
End If
The Exists always returns false (no exception is thrown). I added some
test
code here at this point to open and read the file. That caused it to throw
an
exception of type UnauthorizedAccessException.
What am I doing wrong? Is there a better way to accomplish this task? Any
help will be highly appreciated.
TIA
Khalique
(By the way I have tested the web service by logging on to web server and
using IE to call the web service. That works perfectly fine)


Nov 23 '05 #3
Sorry, I misunderstood. The issue here is called the "double hop" issue.
Try hard coding the user name and password in the web.config file on the
"impersonate" line to represent a network user that has access to the 3rd
computer. The disadvantages are the web app will always run in the context
of this user, and the password is visible in the web.config file, but
someone must have access to the machine to read the password, so maybe it is
not such a big deal.
Read more about "double hop" here:
http://msdn.microsoft.com/library/de..._asp_pages.asp
Also search it in google, there are other solutions, Kerberos, etc, but not
for the faint of heart.

"Khalique" <Kh******@discussions.microsoft.com> wrote in message
news:60**********************************@microsof t.com...
Thanks Chris,
I am setting the credentials before calling the web method. And, inside
the
web method I have checked that it is set properly.
The problem is that Web Service needs to accesss a file on client machine.
And when it does, it does not impersonate the user. However, it does
impersonate when accessing resources on the Web Server because I am able
to
connect and query the SQL Server that is running on the Web Server.
While in Web Method, can we somehow change the credentials? Will that work
in this situation? I mean accessing ressources on client/othermachine?
Khalique
"Chris Botha" wrote:
By default IE passes the credentials with the request, which is not the
default in the client app, so IE works and the app does not. You must set
the credentials explicitly in the client app, either using the
credentials
the user is logged on as, or you can set it to someone else, the latter
the
user types it in for example. The 2 calls look something like this:
myWebService.Credentials = System.Net.CredentialCache.DefaultCredentials
myWebService.Credentials = new System.Net.NetworkCredential(...)
Check out the Credentials property of the web service in the
documentation.

"Khalique" <Kh******@discussions.microsoft.com> wrote in message
news:44**********************************@microsof t.com...
>I have built a web service whose purpose is to copy files from a secure
>place
> to client machine and vice versa. The problem I am having is perhaps
> related
> to permissions and access rights.
> For testing purposes, the secure place is setup on the client machine.
> The client (window app) calls the web service (on a different machine)
> and
> connects successfully to the web service. However, when client calls a
> method
> that copies the file from secure place to client machine (or vice
> versa),
> an
> UnauthorizedAccessException is thrown.
> In web.config file, authentication mode = "windows", identity
> impersonate="true". The secure place folder and the target folder for
> copy
> operation on client machine are publicly shared and have explicitly
> given
> permission to aspnet_wp account. I even allowed Anonymous Logon to
> Read&
> Execute, List Folder Contents and Read. Nothing seems to solve the
> problem.
> The problem occurs when I try to verify the existence of the file (on
> client
> machine) like this:
> Dim fiVault FileInfo = New FileInfo(sVaultFileName)
> If fiVault.Exists
> ...
> End If
> The Exists always returns false (no exception is thrown). I added some
> test
> code here at this point to open and read the file. That caused it to
> throw
> an
> exception of type UnauthorizedAccessException.
> What am I doing wrong? Is there a better way to accomplish this task?
> Any
> help will be highly appreciated.
> TIA
> Khalique
> (By the way I have tested the web service by logging on to web server
> and
> using IE to call the web service. That works perfectly fine)


Nov 23 '05 #4
Thanks Chris forthe help and the reference. I am looking into the possibility
of using kerberos.
Khalique

"Chris Botha" wrote:
Sorry, I misunderstood. The issue here is called the "double hop" issue.
Try hard coding the user name and password in the web.config file on the
"impersonate" line to represent a network user that has access to the 3rd
computer. The disadvantages are the web app will always run in the context
of this user, and the password is visible in the web.config file, but
someone must have access to the machine to read the password, so maybe it is
not such a big deal.
Read more about "double hop" here:
http://msdn.microsoft.com/library/de..._asp_pages.asp
Also search it in google, there are other solutions, Kerberos, etc, but not
for the faint of heart.

"Khalique" <Kh******@discussions.microsoft.com> wrote in message
news:60**********************************@microsof t.com...
Thanks Chris,
I am setting the credentials before calling the web method. And, inside
the
web method I have checked that it is set properly.
The problem is that Web Service needs to accesss a file on client machine.
And when it does, it does not impersonate the user. However, it does
impersonate when accessing resources on the Web Server because I am able
to
connect and query the SQL Server that is running on the Web Server.
While in Web Method, can we somehow change the credentials? Will that work
in this situation? I mean accessing ressources on client/othermachine?
Khalique
"Chris Botha" wrote:
By default IE passes the credentials with the request, which is not the
default in the client app, so IE works and the app does not. You must set
the credentials explicitly in the client app, either using the
credentials
the user is logged on as, or you can set it to someone else, the latter
the
user types it in for example. The 2 calls look something like this:
myWebService.Credentials = System.Net.CredentialCache.DefaultCredentials
myWebService.Credentials = new System.Net.NetworkCredential(...)
Check out the Credentials property of the web service in the
documentation.

"Khalique" <Kh******@discussions.microsoft.com> wrote in message
news:44**********************************@microsof t.com...
>I have built a web service whose purpose is to copy files from a secure
>place
> to client machine and vice versa. The problem I am having is perhaps
> related
> to permissions and access rights.
> For testing purposes, the secure place is setup on the client machine.
> The client (window app) calls the web service (on a different machine)
> and
> connects successfully to the web service. However, when client calls a
> method
> that copies the file from secure place to client machine (or vice
> versa),
> an
> UnauthorizedAccessException is thrown.
> In web.config file, authentication mode = "windows", identity
> impersonate="true". The secure place folder and the target folder for
> copy
> operation on client machine are publicly shared and have explicitly
> given
> permission to aspnet_wp account. I even allowed Anonymous Logon to
> Read&
> Execute, List Folder Contents and Read. Nothing seems to solve the
> problem.
> The problem occurs when I try to verify the existence of the file (on
> client
> machine) like this:
> Dim fiVault FileInfo = New FileInfo(sVaultFileName)
> If fiVault.Exists
> ...
> End If
> The Exists always returns false (no exception is thrown). I added some
> test
> code here at this point to open and read the file. That caused it to
> throw
> an
> exception of type UnauthorizedAccessException.
> What am I doing wrong? Is there a better way to accomplish this task?
> Any
> help will be highly appreciated.
> TIA
> Khalique
> (By the way I have tested the web service by logging on to web server
> and
> using IE to call the web service. That works perfectly fine)


Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Peter | last post by:
Hello, Two newbie questions: 1) I have a javascript file with a function in it. From this function I want to access a variable in another javascript file -which is not inside a function. I...
36
by: Thomas | last post by:
after spending countless hours trying, i give up and hope to get some help in here. on server1 i got the web myweb.com with my test.asp. in the test.asp, i'm trying to read a file from an UNC...
2
by: paulp | last post by:
Greetings, I'm working on a CGI program that will run under MS IIS 5.0 and will browse folders on three other machines, building HTML pages that will provide links to these folders. ...
5
by: paulp | last post by:
Greetings, I'm working on a CGI program that will run under MS IIS 5.0 and will browse folders on three other machines, building HTML pages that will provide links to these folders. ...
5
by: Rosa | last post by:
Hi, I'm experiencing a bit of a problem with security and file access from within a ASP.Net application... Locally (from an XP client) I manage to get any file or folder on my machine with...
2
by: Jon Maz | last post by:
Hi All, I'm in a possibly unusual situation, that is working alternately on an ASP.NET web site from two dev computers, one of which has VS.Net installed on it, the other of which does not. As...
3
by: Baron | last post by:
an asp.net page on Machine A is trying to access files on several machines of different domains.. any 'good' method to do it without mapping drive in prior..... i've read something called...
5
by: Khalique | last post by:
Hi everyone, I Hope that someone will be able to give me a hint to the solution to my problem. I have developed a web service (vb.net) that needs to access the folders / files and copy files to...
3
by: Gerhard | last post by:
I have an application that needs to be able to upload documents that can latter be accessed and opened by a hyperlink. I can do this easliy if I store the files in a subdirectory in the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.