By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,117 Members | 2,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,117 IT Pros & Developers. It's quick & easy.

Accessing files & folders on client/other machine

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.