Re: System.UnauthorizedAccessException

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Joyjit Mukherjee (joyjit_mukherjee_at_hotmail.com)
Date: 09/08/04


Date: Wed, 8 Sep 2004 12:23:17 +0530

Hi,

you need to impersonate the user under whose behalf the resource is going to
be accessed. Put a <identity> tag in ur Web.Config as follows: -

< identity impersonate = "true" userName = "Domain\username" password =
"password" />

Regards
Joyjit

"Peter Afonin" <peter@gudzon.net> wrote in message
news:%23HW$lQTlEHA.3632@TK2MSFTNGP09.phx.gbl...
> Hello,
>
> I'm using this code to access a network share from an asp.net page:
>
> Dim dir As DirectoryInfo = New DirectoryInfo("\\10.0.0.150\FormLib\")
> Dim files() As FileInfo = dir.GetFiles("*.eps")
>
> When I try to do it, I get this error:
>
> System.UnauthorizedAccessException: Access to the path
> "\\10.0.0.150\FormLib\" is denied. at System.IO.__Error.WinIOError(Int32
> errorCode, String str) at
> System.IO.Directory.InternalGetFileDirectoryNames(String fullPath, String
> userPath, Boolean file) at System.IO.Directory.InternalGetFiles(String
path,
> String userPath, String searchPattern) at
> System.IO.DirectoryInfo.GetFiles(String searchPattern) at
> Wip7b.WorkInProcess.btnGetEPS_ServerClick(Object sender, EventArgs e)
>
> All permissions to this folder and a file share are set to
Everyone.Usually
> I don't have this problem. The only thing that is different about this
> particular machine that it is not a part of the domain to which all other
> PCs in our company belong, so I cannot access any users from our Active
> Directory.
>
> This is a Win 2000 SP4 machine.
>
> I would greatly appreciate your help.
>
> Thank you,
>
> --
> Peter
>
>



Relevant Pages

  • Re: System.UnauthorizedAccessException
    ... > System.IO.Directory.InternalGetFileDirectoryNames(String fullPath, String ... > userPath, Boolean file) at System.IO.Directory.InternalGetFiles(String ... > String userPath, String searchPattern) at ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: FileInfo performance
    ... at System.IO.__Error.WinIOError(Int32 errorCode, String str) ... fullPath, String userPath, Boolean file) ... userPath, String searchPattern) ...
    (microsoft.public.dotnet.framework)
  • System.IO.Directory.Delete - access denied exception
    ... at System.IO.Directory.DeleteHelper(String fullPath, String ... at System.IO.Directory.Delete(String fullPath, String userPath, ... I have tried logging in as local admin and domain ...
    (microsoft.public.dotnet.csharp.general)
  • Re: FileInfo performance
    ... at System.IO.__Error.WinIOError(Int32 errorCode, String str) ... fullPath, String userPath, Boolean file) ... userPath, String searchPattern) ...
    (microsoft.public.dotnet.framework)
  • Re: FileInfo performance
    ... The Error message that I get is ... at System.IO.__Error.WinIOError(Int32 errorCode, String str) ... fullPath, String userPath, Boolean file) ...
    (microsoft.public.dotnet.framework)