Access to the path .... is denied

Discussion in 'ASP .Net' started by j_stus@hotmail.com, May 15, 2006.

  1. Guest

    Here is my problem.
    I reported this before, I got some tips and resolved some of the
    problems, but still not the way it would satisfy me and my needs...

    I try to execute this code.

    Dim myFolder As String = Server.MapPath("..\..\..\sDirectory\")
    Dim FileName As String

    For Each FileName In Directory.GetFiles(myFolder , "*.doc")
    Response.Write(FileName)
    Exit For
    Next

    sDirectory is a virtual directory that points to some location on
    another computer which is w2000 server.
    My website is on another computer which is w2003 server.

    On my domain I created new user. This user has rights to sDirectory.
    If I modify my web.config to <identity impersonate="true"
    userName="DOMAIN\user" password="somepassword"></identity>
    it will list all my files.
    I cannot do it though, because I am not writing new website. I am just
    modifying existing one, and if I would modify webconfig, it would brake
    other parts of the code.

    I tried to change identity "on fly"
    Dim tokenHandle As New IntPtr(0)
    Dim dupeTokenHandle As New IntPtr(0)
    tokenHandle = IntPtr.Zero
    LogonUser(userName, domainName, password, 3, 0, tokenHandle)
    Dim newId As New WindowsIdentity(tokenHandle)
    Dim impersonatedUser As WindowsImpersonationContext =
    newId.Impersonate()
    Even though user name, password and domain are the same as in identity
    impersonate, it would not let me list files...

    now I am stuck, not sure what I can try next....
    My ASP version is v1.1.4322
     
    , May 15, 2006
    #1
    1. Advertising

  2. rjl Guest

    try adding asp.net user account to read/write to the security tab of
    the directory.
     
    rjl, May 16, 2006
    #2
    1. Advertising

  3. Guest

    I think I found a way to do it.
    Once I test everything I will post my findings:)
    Thanks
     
    , May 16, 2006
    #3
  4. Guest

    , May 23, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Theerachet Pratoommanee

    Access to the path is denied

    Theerachet Pratoommanee, Dec 30, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    8,399
    Sachin Kharsani[MSFT]
    Dec 30, 2003
  2. cg
    Replies:
    0
    Views:
    490
  3. S. Justin Gengo
    Replies:
    0
    Views:
    887
    S. Justin Gengo
    Jul 14, 2003
  4. Jay
    Replies:
    2
    Views:
    1,117
  5. Kent Tegels
    Replies:
    0
    Views:
    250
    Kent Tegels
    Aug 26, 2004
Loading...

Share This Page