Ask a Question related to ASP.NET Web Services, Design and Development.
-
Maarten #1
Re: Access to Path is denied
What account is your webservice running under? aspnet? Does aspnet have
access to the directory?
Maarten
"Eric Levin" <eric@soundsite.com> wrote in message
news:OdTrgmobDHA.2820@tk2msftngp13.phx.gbl...FileIOPermissionAttributes,> I am trying to call a DirectoryInfo.Delete function from a Web Service but
> am getting an Access Denied Error:
> System.UnauthorizedAccessException: Access to Path "..." is Denied.
>
> I have tried using Impersonation and setting the> but am still getting the same error:
>
> Thanks,
>
> [WebMethod]
> //[FileIOPermissionAttribute(SecurityAction.PermitOnl y, Write =
> "F:\\DirectoryName")]
> public bool DeleteDirectory(string Directory)
> {
> //ImpersonateUser("UserName", "Password", "MACHINE/DOMAIN");
> string FTPPath = @"f:\DirectoryName\" + Directory;
> FileIOPermission f; // = new FileIOPermission(PermissionState.None);
> f = new FileIOPermission(FileIOPermissionAccess.AllAccess, FTPPath);
> DirectoryInfo ftp = new DirectoryInfo(FTPPath);
> ftp.Delete(true);
> ftp.Refresh();
> //StopImpersonateUser();
> if (ftp.Exists == true)
> return false;
> else
> return true;
> }
>
> Eric Levin
> Sounddogs.com
>
>
>
>
>
>
>
Maarten Guest
-
Access to path is denied...
I'm trying to test/check contents of a dataset by writing it to an xml file on the server, but get this error above. The suggestion to grant... -
Access to path denied
I have a question. I am running Windows 2003 Server with Framework 1.1. I have an application that has XML config files within it that drive part... -
Access to the path is denied
This is error message I've got. Any suggestion would be appreciated. Server Error in '/WebDirectory' Application. ... -
System.UnauthorizedAccessException: Access to the path is denied
Server Error in '/BIP' Application. ----------------------------------------------------------- --------------------- Access to the path... -
Access to the path ...\\dynamic_images is denied. What Happens???
I have designed a report that uses the CrystalReportViewer which works fine on my local machine. I created a setup to install Crystal Report in my... -
Matthew Holton #2
Access to Path is denied
Eric,
I had a similar issue, here is how i resolved it:
1. require the webservice to use NT AUTH, set that up in
IIS for that virtual root.
2. Refresh you webservice reference
3. In your webservice reference, open Reference.vb and
put in
.... (VB Snippet, convert to C#)
Protected Overrides Function GetWebRequest(ByVal uri
As System.Uri) As System.Net.WebRequest
'This will force presentation of credentials
'Turns off persistance with wp
Dim mHttpWebRequest As System.Net.HttpWebRequest =
MyBase.GetWebRequest(uri)
mHttpWebRequest.KeepAlive = False
Return mHttpWebRequest
End Function
....
This will need to be put in each time you refresh your
webservice reference. It forces the credentials to be
evaluated each time a request is made. The alternative
is, once a sucessful AUTH is made, noone else is validated.
4. Before you call the webservice.DeleteDirectory
.... (VB Snippet, convert to C#)
'Create an instance of our webservice
Dim objImpersonator As WebService.FileIO = New
WebService.FileIO()
'Get the location of our webservice
objImpersonator.Url =
System.Configuration.ConfigurationSettings.AppSett ings.Get
("WebService.FileIO.Connector")
'Create credentials to connect to our webserivce
Dim objCredential As System.Net.NetworkCredential
Dim objCache As New System.Net.CredentialCache()
objCredential = New System.Net.NetworkCredential
(sUserName, sPassword, sDomainName)
'objCache.Add(New System.Uri
(objImpersonator.Url), "Basic", objCredential)
'Present our credentials
objImpersonator.Credentials =
objCredential 'objCache
iRet = objImpersonator.DeleteDirectory
(sPathToDelete)
....
5. Place your web serivce server on a DMZ, but away from
public eyes. This way you wont need a certificate and
wont have to worry about people monitoring this traffic
and getting UID/PWD.
HTH,
Matthew Holtona Web Service but>-----Original Message-----
>I am trying to call a DirectoryInfo.Delete function fromis Denied.>am getting an Access Denied Error:
>System.UnauthorizedAccessException: Access to Path "..."FileIOPermissionAttributes,>
>I have tried using Impersonation and setting theWrite =>but am still getting the same error:
>
>Thanks,
>
>[WebMethod]
>//[FileIOPermissionAttribute(SecurityAction.PermitOnl y,("UserName", "Password", "MACHINE/DOMAIN");>"F:\\DirectoryName")]
>public bool DeleteDirectory(string Directory)
>{
> //ImpersonateUser(PermissionState.None);> string FTPPath = @"f:\DirectoryName\" + Directory;
> FileIOPermission f; // = new FileIOPermission(FileIOPermissionAccess.AllAccess, FTPPath);> f = new FileIOPermission> DirectoryInfo ftp = new DirectoryInfo(FTPPath);
> ftp.Delete(true);
> ftp.Refresh();
> //StopImpersonateUser();
> if (ftp.Exists == true)
> return false;
> else
> return true;
>}
>
>Eric Levin
>Sounddogs.com
>
>
>
>
>
>
>
>.
>Matthew Holton Guest



Reply With Quote

