Last post Oct 06, 2009 11:33 PM by atconway
Oct 01, 2009 04:57 PM|Vivek2812|LINK
I wrote WCF method that check whether file is available or not.
File is on the network drive.
When I am checking file is available or not. Web service is returning me "file not found"
Please let me know what should I do to fix it.
WCF "web services"
Oct 02, 2009 06:22 AM|integrasol|LINK
This could well be a permission problem, in that the account used by the application for the WCF service doesn't have read access permission to the folder or even drive. Excerpt from
If the caller does not have sufficient permissions to read the specified file, no exception is thrown and the method returns
false regardless of the existence of path.
Check here for options on how to request this permission, which will throw an exception if not granted:
Oct 02, 2009 01:11 PM|Vivek2812|LINK
Thanks for the reply. I am new to WCF or Web Services.
I wrote a web service to get image byte array from Network file.
Before doing actual operation I was checking whether file exists or not.
I posted web services using IIS 6.0 server.
I am accessing image data files on the same machine. I am providing complete UNC path to refer them.
In web service my web.config file has <identity impersonate="true"/> tag also.
I am accessing above WCF using SilverLight 3.0
But Still I am getting file not found error. I was thinking that if SilverLight + WCF + Image data files are
sitting on same box then it should not give any problem.
Please let me know how can I resolve it.
Oct 02, 2009 02:37 PM|atconway|LINK
Take a look to the follwing thread which discusses the same topic:
File.Exists and UNC paths:
It is probably a permissions isuue with either the ASPNET account to that directory or to the user that is being impersonated.
At times when I have had difficulty with using the System.IO namespace because of permissions, I wrap the individual code in Impersonation logic using an elevated account which also works well too. Here is an article on impersonation in code if you need
to go that far (I don;t think you will, but it could be useful anyways):
Oct 02, 2009 03:26 PM|Vivek2812|LINK
Thanks atconway I gave ASPNET access to web service folder, silverlight deployment folder and image data folder. It has read and read & execute permission. But still I am seeing same results. How can I use WindowsImpersonationContext
Please let me know if you can share some samples. My environment is IIS6 + silverlight 3 + WCF + image data file on network drive.
Oct 02, 2009 04:38 PM|atconway|LINK
1st, take a look at the example in the MSDN article below; it has a great coding example and is the one I use for Impersonating a Windows user:
2nd, don't get spend too much time with the Impersonation code before making a post in the Silverlight forums. I have worked with Silverlight myself, and the security issues you are having may be with Silverlight and not ASP.NET. The user you are using
for running the ASP.NET app may not get propogated over to the Silverlight control and therefore be the root cause of the issue. If this was the case, then impersonating a user
could be a possible solution. The Silverlight forums can be found here:
Oct 05, 2009 09:50 AM|Vivek2812|LINK
I tried ImpersonateUser() class as well. and still I am getting same "no file found" result.
'Dim iu As New ImpersonateUser()
'ImpersonateUser.impersonateValidUser("username", "domain", "password")
'If ImpersonateUser.p_impersonationContext IsNot Nothing Then
' MessageBox.Show("context isnot nothing.")
'iu = Nothing
Oct 05, 2009 10:02 AM|integrasol|LINK
I gave ASPNET access to web service folder, silverlight deployment folder and image data folder
Did you check the application pool identity used for your Web service in IIS? It uses the NETWORK SERVICE account by default.
Oct 05, 2009 10:46 AM|Vivek2812|LINK
You are right. At present DefaultAppPool identity is set to NETWORK SERVICE. Is it correct?
Oct 05, 2009 10:56 AM|integrasol|LINK
Yes, but what I meant to imply is that you need to give that account access rights, if anonymous access has been disabled.
Oct 05, 2009 04:12 PM|atconway|LINK
If you impersonated an elevated account (i.e. Administrator) and ran the System.IO code to access the file, and
still could not access the file, then granting access to the machine 'NETWORK SERVICE' account will probably not solve the problem (although it is the right thing to do anyways so when this all gets fixed you do not need impersonation).
Before we get too far down the wrong path, is it possible that the file really does not exist or is not in the path you are searching for it? Try debugging and monitoring for the file path; it could be possible that you are not loking in the right
Oct 06, 2009 12:19 PM|Vivek2812|LINK
Thanks to you Atconway and Carsten. Today I sat with my network guy and explored all options related to security. At one place "Network Service" account access was missing.
As we granted access to the machine "Network Service" account. It started working great.
I appreciate you guys efforts and time. For me it was good learning experience. One last thing can you guys share your web.config file (for web service) and ServiceReferences.ClientConfig file for silver light 3.0? So I will learn what security settings
I should have. My email id is firstname.lastname@example.org.
Oct 06, 2009 11:33 PM|atconway|LINK
One last thing can you guys share your web.config file (for web service)
There are so many different WCF .config configurations, so copy and pasting my WCF configuration for you could be pointless because it may just confuse you more if we are using a different communication protocall (i.e. http, net.tcpip, etc) or security
My advice for you is this: understand the best you can what the config file in WCF is
actually doing and responsible for. Just simply looking at somebody elses .config for WCF will not be good enough to be a permanent template for configuraing your service. You need to understand what is going on in the configuration.
To that end, I have a few links that I reccomend you read to help you achieve this:
Configuring Services Using Configuration Files:
...(this one is overwhelming, but is a nice tree to understand the configuration)
Windows Communication Foundation Configuration Schema:
Configuration Editor Tool (SvcConfigEditor.exe):
One last thing. WCF configuration is not immedeatly clear or easy at first
especially if security is added to the endoint. I even hear the best in the industry give these same sentimates that it is difficult at times to get it properly configured and deployed. Your best approach is to understand it, so that subsiquient serivces
will be easier to configure.