Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / February 2005

Tip: Looking for answers? Try searching our database.

Accessing files & folders on client/other machine

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Khalique - 02 Feb 2005 15:41 GMT
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)
Chris Botha - 02 Feb 2005 18:09 GMT
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.

>I have built a web service whose purpose is to copy files from a secure
>place
[quoted text clipped - 32 lines]
> (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)
Khalique - 02 Feb 2005 18:43 GMT
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

> 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
[quoted text clipped - 41 lines]
> > (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)
Chris Botha - 02 Feb 2005 20:12 GMT
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/default.asp?url=/library/en-us/sds/sds/trouble
shooting_authentication_problems_on_asp_pages.asp

Also search it in google, there are other solutions, Kerberos, etc, but not
for the faint of heart.

> Thanks Chris,
> I am setting the credentials before calling the web method. And, inside
[quoted text clipped - 65 lines]
>> > and
>> > using IE to call the web service. That works perfectly fine)
Khalique - 07 Feb 2005 14:59 GMT
Thanks Chris forthe help and the reference. I am looking into the possibility
of using kerberos.
Khalique

> 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
[quoted text clipped - 77 lines]
> >> > and
> >> > using IE to call the web service. That works perfectly fine)

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.