Access to the path .... is denied


J

j_stus

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
 
Ad

Advertisements

J

j_stus

I think I found a way to do it.
Once I test everything I will post my findings:)
Thanks
 
Ad

Advertisements


Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top