473,394 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

grabbing UNC path from asp.net multipart form browse

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.

Jan 15 '07 #1
4 3087
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...

----
Patrice

"DMG" <Da**********@gmail.coma écrit dans le message de news:
11**********************@q2g2000cwa.googlegroups.c om...
>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.

Jan 15 '07 #2
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

Patrice wrote:
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...

----
Patrice

"DMG" <Da**********@gmail.coma écrit dans le message de news:
11**********************@q2g2000cwa.googlegroups.c om...
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.
Jan 15 '07 #3
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" <Da**********@gmail.coma écrit dans le message de news:
11**********************@v45g2000cwv.googlegroups. com...
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

Patrice wrote:
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...

----
Patrice

"DMG" <Da**********@gmail.coma écrit dans le message de news:
11**********************@q2g2000cwa.googlegroups.c om...
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.

Jan 15 '07 #4
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
Patrice wrote:
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" <Da**********@gmail.coma écrit dans le message de news:
11**********************@v45g2000cwv.googlegroups. com...
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

Patrice wrote:
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...

----
Patrice

"DMG" <Da**********@gmail.coma écrit dans le message de news:
11**********************@q2g2000cwa.googlegroups.c om...
>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.
>
Jan 15 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Matt | last post by:
The user can select a file in the file open dialog using <input type="FILE">, but the user can also enter the full file path in the browse text box manually. My question is if there are JavaScript...
3
by: Matt | last post by:
<input type="file" size=50"> will produce the browse button and browse text box. The user can either select the file from browse button, or enter a path in browse text box manually. My question...
4
by: John Fereira | last post by:
So, one of the limitations of multipart-form handling is that when an <input type="file" ..> tag is used it will bring up a window which allows a user to select a file for upload but won't allow...
4
by: Alex Sibilev | last post by:
Hello, I have a really weird problem I've been trying to solve it without any luck for the last couple of hours :( I'm writing a "conference board" application (quite similar to ASP.NET...
4
by: bwalke | last post by:
Help Needed Please!!! With a VB.NET web application, I am trying to save pictures and files to a directory on the web server. However, the web server is not grabbing the Posted Files. For...
4
by: kevin | last post by:
Hi, I am trying to create a page so the user can browse the network, select a file and have that file name (text) inserted into our sql DB so I can build the hyperlink path later on. Here's what...
1
by: Glenn Coyle | last post by:
Hi I am having trouble writing the file path of a image to the database,also for some reason it is not uploading the images, anyone have any ideas? the code is below: if($_POST ==...
3
by: wreed | last post by:
Is there a way on a button press to create a browse for a file box and then when they pick a file on a share drive to convert it to a UNC path and that way I would save the unc path into a table...
1
by: nad2zen | last post by:
Hi All, How to set the path value to file object using javascript. now i am trying to upload the file without using browse button, but i could not set the path value.. see my code: <form...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.