grabbing UNC path from asp.net multipart form browse

D

DMG

I have <identity impersonate = "true" /> & <authentication
mode="Windows"/> in the web.config. This is a 2.0 site. My Goal: I
want to simply have the user browse to a file on a mapped drive and get
the UNC for that file and eventually save that unc path to the database
as a link. The problem is depending on office we have the same drive
letter mapped to different servers.

My current test works when I run everything locally and maps correctly
to even a network drive. It fails when I deploy to a production server
with the following error.

Error:
System.Web.HttpUnhandledException: Exception of type
'System.Web.HttpUnhandledException' was thrown. --->
System.Runtime.InteropServices.COMException (0x800A0044): Exception
from HRESULT: 0x800A0044 (CTL_E_DEVICEUNAVAILABLE)
at Scripting.FileSystemObjectClass.GetDrive(String DriveSpec)

asp.net 2.0 c# Code:
string sTemp = filepath.Value.ToString(); // mapped drive/file
input string
Scripting.FileSystemObject FSO = new
Scripting.FileSystemObject();
Scripting.Drive Drive = FSO.GetDrive(sTemp.Substring(0, 2));
<== error line

...

I have tried to impersonate an account (using advapi32.dll LogonUser())
that has heightened authority but that fails as well - I can provide
details . Perhaps I am just missing the right setting on that account.

Thanks in advance for any help.
 
P

Patrice

1) You likely don't have any more to use Scripting.fileSystemObject. See
System.IO that should provide similar .NET based capabilities.

2) It looks like to me you are trying to access a drive letter server side.
This driver letter likely doesn't exists server side...

So :
- I would try first with something constant that should work (use
FSO.GetDrive("e:") or print out sTemp.Substring(0,2) to be sure to do what
you expect).
- I'm not sure how it could be solved. The drive letter to UNC resolution
can only be done IMO client side as this is workstation specific.

Or is it that you try to use Scripting.FileSystemobject client side ? Keep
in mind that the ASPX page runs server side. To do so you would have to
inject client side code in your page plus likely to alter security
settings...
 
D

DMG

Patrice,

Thanks for your response. I am indeed trying to resolve the client's
drive reference mapping to a UNC path. My goal is related to uploading
a file from a client workstation and they are browsing to a network
resource on a mapped drive. They choose a file to upload but in my case
I just want the UNC path to that resource to save as a link - I do not
want to copy the file just how to get to it as a UNC.

Regards,
dmg
 
P

Patrice

Ok, so as I said earlier it looks like to me you are trying to do this
server side where the client computer letter drive mappings are not known.
Is this that ?

If yes, you must do this client side using JavaScript code. Give it a try
and open a new thread if you have some difficulties (likely you'll have to
alter first the secuirty settings, for example by putting this site in the
"trusted" zone). You must run Scripting.FileSystemObject *client side*.

Also as I said ealier before doing the actual coding, just write bare bone
code for a proof of concept (basically a javascript code that is hosted in a
web page and find out the mapping for you e: drive or whatever letter you
want). It will likely help you to see the big picture before dealing with
details...

Also you'll have this likely in many more occasion if they have each their
own mapping. It could perhaps be worth to see if it can be standardized...

Good luck.

Patrice

"DMG" <[email protected]> a écrit dans le message de
(e-mail address removed)...
Patrice,

Thanks for your response. I am indeed trying to resolve the client's
drive reference mapping to a UNC path. My goal is related to uploading
a file from a client workstation and they are browsing to a network
resource on a mapped drive. They choose a file to upload but in my case
I just want the UNC path to that resource to save as a link - I do not
want to copy the file just how to get to it as a UNC.

Regards,
dmg
 
D

DMG

Patrice,

Thanks again for your replies. I wish our drives were standardized but
that is not my call. For what it is worth I do have this working if I
run the site locally so I am able given the level of trust (I guess) to
do this without any js. To restate this: I can when running the website
locally pass the mapped drived via a multipart form browse and using
FSO.getDrive() get the UNC. It loses either its security context and
or just the fact that it is on another machine & therefore can not
resolve the mapping when I run on a production server and it hit it
remotely. (This is - as you can guess - an intranet application so if
this is just a security issue: I can get the account security setup
correctly just need to know where to do so. )

Awhile back I saw an article that presented code for getting what the
client's mapped drive really pointed to but I can no longer locate it.
Perhaps it was just client side app to begin with & had access to their
mappings instead of a web based solution. Until I solve this I have a
work around that will just force the user to indicate their location
(or get it from AD) which will give me what I know to resolve the
relative mapping.

Thanks,
DMG
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top