Question

ASP File Upload FileSystemObject Permission Denied

Asked by: MDauphinais1

I cannot seem to wrap my head around this so I need some help.

Ultimately, I need to upload a file with ASP to a remote file store server (all within my corporate network - just a different server from the web server).

First, I am using FreeASPUpload to do the upload - found on the web for free and shown below.

Second, I have a virtual directory set up on IIS pointing to the remote file share. The anonymous permissions are configured for a domain account that has Read/Write/Modify access to the remote file server.

I have the upload script working perfectly when uploading to the web server. When I tried changing it to the virtual directory I kept getting Permission Denied and I could not figure out why. After some reading about the FreeASPUpload script I found out that it cannot upload to a virtual directory, for whatever reason. They blame it on the ADODB.Stream procedure.

So I am trying to create a work-a-round. What I did was upload the file to the local web server - which works fine - and then I am using FileSystemObject to copy the file to the virtual directory and delete it from the web server. In essence I am using the web server as a transfer point.

If I just take the FileSystemObject code attached and run it independently as its own script, in its own web browser window, the file gets copied to the virtual directory and deleted from the web server just fine. However, if I try to run the script as part of the FreeASPUpload procedure or even from within the same browser window I get "Permission Denied".

So I was thinking that for some reason the file upload was doing something to the permissions on my session so the IIS server no longer knew who I was (even though it is suppose to be using the anonymous user account specified) which doesn't make any sense. So I tried running the FreeASPUpload script, and then using JavaScript to popup a new browser window to run the FileSystemObject script and then close the browser window. I still get Permission Denied in the popup page. But if I take the URL from the popup page and manually open a new browser window, paste the URL and hit enter the code runs fine. I even tried delaying the opening of the popup page thinking the upload might be taking a second that that didn't help.

I cannot figure this out and it is driving me nuts. Any ideas?

/// FILESYSTEMOBJECT CODE ///
 
<%
Dim uploadsDirRemote, uploadsDirLocal, filename
uploadsDirLocal = Server.MapPath("\") & "\Public\doc_transfer\"
If request.querystring("interface") = "Event" Then
uploadsDirRemote = Server.MapPath("/Remote/public_files/") & "\DeptStorage\Files\" & request.querystring("id") & "\"
End If
filename = request.querystring("filename")
 
response.write uploadsDirRemote
 
    '### CREATE REMOTE STORAGE FOLDER ###
    Set fs = Server.CreateObject("Scripting.FileSystemObject")
    If fs.FolderExists(uploadsDirRemote) = true then
    'Folder already exists, do not create folder
    Else
    fs.createfolder(uploadsDirRemote) 
    End If
    '### TRANSFER TEMP FILE TO REMOTE STORAGE ###
    Set f = fs.GetFile(uploadsDirLocal & filename)
    f.Copy uploadsDirRemote & "\" & filename,true
    Set f = Nothing
    '### DELETE TEMP FILE ###
    fs.CreateTextFile uploadsDirLocal & filename,True
    If fs.FileExists(uploadsDirLocal & filename) then
    fs.DeleteFile(uploadsDirLocal & filename)
    End If
    Set fs = Nothing
Response.Write("<SCRIPT>window.close()</SCRIPT>")
%>
 
 
/// FREEASPUPLOAD CODE ///
 
<%@ Language=VBScript %>
<% 
option explicit 
Response.Expires = -1
Server.ScriptTimeout = 600
%>
<!-- #include file="..\database_connect\mssql_connect.asp" -->
 
<%
Class FreeASPUpload
	Public UploadedFiles
	Public FormElements
 
	Private VarArrayBinRequest
	Private StreamRequest
	Private uploadedYet
 
	Private Sub Class_Initialize()
		Set UploadedFiles = Server.CreateObject("Scripting.Dictionary")
		Set FormElements = Server.CreateObject("Scripting.Dictionary")
		Set StreamRequest = Server.CreateObject("ADODB.Stream")
		StreamRequest.Type = 1 'adTypeBinary
		StreamRequest.Open
		uploadedYet = false
	End Sub
	
	Private Sub Class_Terminate()
		If IsObject(UploadedFiles) Then
			UploadedFiles.RemoveAll()
			Set UploadedFiles = Nothing
		End If
		If IsObject(FormElements) Then
			FormElements.RemoveAll()
			Set FormElements = Nothing
		End If
		StreamRequest.Close
		Set StreamRequest = Nothing
	End Sub
 
	Public Property Get Form(sIndex)
		Form = ""
		If FormElements.Exists(LCase(sIndex)) Then Form = FormElements.Item(LCase(sIndex))
	End Property
 
	Public Property Get Files()
		Files = UploadedFiles.Items
	End Property
 
	'Calls Upload to extract the data from the binary request and then saves the uploaded files
 
' ///// START OF CUSTOM CODE /////
 
	Public Function FilesSave(path, linkid, interface)
		Dim streamFile, fileItem, SQL, record_check, rs, total, rs1, SQL1, doctitle
 
		doctitle = Request.QueryString("title")
 
		if Right(path, 1) <> "\" then path = path & "\"
 
		if not uploadedYet then Upload
 
		For Each fileItem In UploadedFiles.Items
			Set streamFile = Server.CreateObject("ADODB.Stream")
			streamFile.Type = 1
			streamFile.Open
			StreamRequest.Position=fileItem.Start
			StreamRequest.CopyTo streamFile, fileItem.Length
			streamFile.SaveToFile path & fileItem.FileName, 2
			streamFile.close
			Set streamFile = Nothing
			Response.Write "<SCRIPT type='text/javascript'>self.setTimeout('window.open(\'../Modules/upload_sub.asp?id=" & linkid & "&interface=" & interface & "&filename=" & fileItem.FileName & "&title=" & doctitle & "&size=" & fileItem.Length & "\');$(\'#uploading\').hide();$(\'#fileresults\').show();', 10000)</SCRIPT>"
'Response.Redirect "../Modules/upload_sub.asp?id=" & linkid & "&interface=" & interface & "&filename=" & fileItem.FileName & "&title=" & doctitle & "&size=" & fileItem.Length
			response.write "<span id=fileresults><br><B>File uploaded successfully!</B><br><br><br><table><tr><td><u>File Details</u><br>"
			response.write "File Title: " & doctitle & "<br>File Name: " & fileItem.FileName & " <br>File Size: " & fileItem.Length & " Bytes</td></tr></table></span>"
		 Next
	End Function
 
' ///// END OF CUSTOM CODE /////
 
	Public Function SaveBinRequest(path) ' For debugging purposes
		StreamRequest.SaveToFile path & "\debugStream.bin", 2
	End Function
 
	Public Sub DumpData() 'only works if files are plain text
		Dim i, aKeys, f
		response.write "Form Items:<br>"
		aKeys = FormElements.Keys
		For i = 0 To FormElements.Count -1 ' Iterate the array
			response.write aKeys(i) & " = " & FormElements.Item(aKeys(i)) & "<BR>"
		Next
		response.write "Uploaded Files:<br>"
		For Each f In UploadedFiles.Items
			response.write "Name: " & f.FileName & "<br>"
			response.write "Type: " & f.ContentType & "<br>"
			response.write "Start: " & f.Start & "<br>"
			response.write "Size: " & f.Length & "<br>"
		 Next
   	End Sub
 
	Private Sub Upload()
		Dim nCurPos, nDataBoundPos, nLastSepPos
		Dim nPosFile, nPosBound
		Dim sFieldName, osPathSep, auxStr
 
		'RFC1867 Tokens
		Dim vDataSep
		Dim tNewLine, tDoubleQuotes, tTerm, tFilename, tName, tContentDisp, tContentType
		tNewLine = Byte2String(Chr(13))
		tDoubleQuotes = Byte2String(Chr(34))
		tTerm = Byte2String("--")
		tFilename = Byte2String("filename=""")
		tName = Byte2String("name=""")
		tContentDisp = Byte2String("Content-Disposition")
		tContentType = Byte2String("Content-Type:")
 
		uploadedYet = true
 
		on error resume next
		VarArrayBinRequest = Request.BinaryRead(Request.TotalBytes)
		if Err.Number <> 0 then 
			response.write "<br><br><B>System reported this error:</B><p>"
			response.write Err.Description & "<p>"
			response.write "The most likely cause for this error is the incorrect setup of AspMaxRequestEntityAllowed in IIS MetaBase. Please see instructions in the <A HREF='http://www.freeaspupload.net/freeaspupload/requirements.asp'>requirements page of freeaspupload.net</A>.<p>"
			Exit Sub
		end if
		on error goto 0 'reset error handling
 
		nCurPos = FindToken(tNewLine,1) 'Note: nCurPos is 1-based (and so is InstrB, MidB, etc)
 
		If nCurPos <= 1  Then Exit Sub
		 
		'vDataSep is a separator like -----------------------------21763138716045
		vDataSep = MidB(VarArrayBinRequest, 1, nCurPos-1)
 
		'Start of current separator
		nDataBoundPos = 1
 
		'Beginning of last line
		nLastSepPos = FindToken(vDataSep & tTerm, 1)
 
		Do Until nDataBoundPos = nLastSepPos
			
			nCurPos = SkipToken(tContentDisp, nDataBoundPos)
			nCurPos = SkipToken(tName, nCurPos)
			sFieldName = ExtractField(tDoubleQuotes, nCurPos)
 
			nPosFile = FindToken(tFilename, nCurPos)
			nPosBound = FindToken(vDataSep, nCurPos)
			
			If nPosFile <> 0 And  nPosFile < nPosBound Then
				Dim oUploadFile
				Set oUploadFile = New UploadedFile
				
				nCurPos = SkipToken(tFilename, nCurPos)
				auxStr = ExtractField(tDoubleQuotes, nCurPos)
                ' We are interested only in the name of the file, not the whole path
                ' Path separator is \ in windows, / in UNIX
                ' While IE seems to put the whole pathname in the stream, Mozilla seem to 
                ' only put the actual file name, so UNIX paths may be rare. But not impossible.
                osPathSep = "\"
                if InStr(auxStr, osPathSep) = 0 then osPathSep = "/"
				oUploadFile.FileName = Right(auxStr, Len(auxStr)-InStrRev(auxStr, osPathSep))
 
				if (Len(oUploadFile.FileName) > 0) then 'File field not left empty
					nCurPos = SkipToken(tContentType, nCurPos)
					
                    auxStr = ExtractField(tNewLine, nCurPos)
                    ' NN on UNIX puts things like this in the streaa:
                    '    ?? python py type=?? python application/x-python
					oUploadFile.ContentType = Right(auxStr, Len(auxStr)-InStrRev(auxStr, " "))
					nCurPos = FindToken(tNewLine, nCurPos) + 4 'skip empty line
					
					oUploadFile.Start = nCurPos-1
					oUploadFile.Length = FindToken(vDataSep, nCurPos) - 2 - nCurPos
					
					If oUploadFile.Length > 0 Then UploadedFiles.Add LCase(sFieldName), oUploadFile
				End If
			Else
				Dim nEndOfData
				nCurPos = FindToken(tNewLine, nCurPos) + 4 'skip empty line
				nEndOfData = FindToken(vDataSep, nCurPos) - 2
				If Not FormElements.Exists(LCase(sFieldName)) Then 
					FormElements.Add LCase(sFieldName), String2Byte(MidB(VarArrayBinRequest, nCurPos, nEndOfData-nCurPos))
				else
                    FormElements.Item(LCase(sFieldName))= FormElements.Item(LCase(sFieldName)) & ", " & String2Byte(MidB(VarArrayBinRequest, nCurPos, nEndOfData-nCurPos)) 
                end if 
 
			End If
 
			'Advance to next separator
			nDataBoundPos = FindToken(vDataSep, nCurPos)
		Loop
		StreamRequest.Write(VarArrayBinRequest)
	End Sub
 
	Private Function SkipToken(sToken, nStart)
		SkipToken = InstrB(nStart, VarArrayBinRequest, sToken)
		If SkipToken = 0 then
			Response.write "Error in parsing uploaded binary request."
			Response.End
		end if
		SkipToken = SkipToken + LenB(sToken)
	End Function
 
	Private Function FindToken(sToken, nStart)
		FindToken = InstrB(nStart, VarArrayBinRequest, sToken)
	End Function
 
	Private Function ExtractField(sToken, nStart)
		Dim nEnd
		nEnd = InstrB(nStart, VarArrayBinRequest, sToken)
		If nEnd = 0 then
			Response.write "Error in parsing uploaded binary request."
			Response.End
		end if
		ExtractField = String2Byte(MidB(VarArrayBinRequest, nStart, nEnd-nStart))
	End Function
 
	'String to byte string conversion
	Private Function Byte2String(sString)
		Dim i
		For i = 1 to Len(sString)
		   Byte2String = Byte2String & ChrB(AscB(Mid(sString,i,1)))
		Next
	End Function
 
	'Byte string to string conversion
	Private Function String2Byte(bsString)
		Dim i
		String2Byte =""
		For i = 1 to LenB(bsString)
		   String2Byte = String2Byte & Chr(AscB(MidB(bsString,i,1))) 
		Next
	End Function
End Class
 
Class UploadedFile
	Public ContentType
	Public Start
	Public Length
	Public Path
	Private nameOfFile
 
    ' Need to remove characters that are valid in UNIX, but not in Windows
    Public Property Let FileName(fN)
        nameOfFile = fN
        nameOfFile = SubstNoReg(nameOfFile, "\", "_")
        nameOfFile = SubstNoReg(nameOfFile, "/", "_")
        nameOfFile = SubstNoReg(nameOfFile, ":", "_")
        nameOfFile = SubstNoReg(nameOfFile, "*", "_")
        nameOfFile = SubstNoReg(nameOfFile, "?", "_")
        nameOfFile = SubstNoReg(nameOfFile, """", "_")
        nameOfFile = SubstNoReg(nameOfFile, "<", "_")
        nameOfFile = SubstNoReg(nameOfFile, ">", "_")
        nameOfFile = SubstNoReg(nameOfFile, "|", "_")
    End Property
 
    Public Property Get FileName()
        FileName = nameOfFile
    End Property
 
    'Public Property Get FileN()ame
End Class
 
 
' Does not depend on RegEx, which is not available on older VBScript
' Is not recursive, which means it will not run out of stack space
Function SubstNoReg(initialStr, oldStr, newStr)
    Dim currentPos, oldStrPos, skip
    If IsNull(initialStr) Or Len(initialStr) = 0 Then
        SubstNoReg = ""
    ElseIf IsNull(oldStr) Or Len(oldStr) = 0 Then
        SubstNoReg = initialStr
    Else
        If IsNull(newStr) Then newStr = ""
        currentPos = 1
        oldStrPos = 0
        SubstNoReg = ""
        skip = Len(oldStr)
        Do While currentPos <= Len(initialStr)
            oldStrPos = InStr(currentPos, initialStr, oldStr)
            If oldStrPos = 0 Then
                SubstNoReg = SubstNoReg & Mid(initialStr, currentPos, Len(initialStr) - currentPos + 1)
                currentPos = Len(initialStr) + 1
            Else
                SubstNoReg = SubstNoReg & Mid(initialStr, currentPos, oldStrPos - currentPos) & newStr
                currentPos = oldStrPos + skip
            End If
        Loop
    End If
End Function
%>
 
 
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" src="../java/jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="../java/ajax.js"></script>
<script type="text/javascript" src="../java/functions.js"></script>
<link rel="stylesheet" href="../style/default.css">
</head>
 
<% If Request.QueryString("tabupdated") = 2 Then %>
<body onload='$("#fileselected").hide();$("#fileresults").hide();'>
<% Else %>
<body onload='$("#fileselected").hide();'>
<% End If %>
<%
 
 
' *********************** START VARIABLE EDIT ***********************
 
  Dim uploadsDirRemote, uploadsDirLocal
 
  uploadsDirLocal = Server.MapPath("\") & "\Public\doc_transfer"
 
' ************************ END VARIABLE EDIT ************************
 
function OutputForm()
%>
 
 
<% Response.Write "<form name='frmSend' method='POST' enctype='multipart/form-data' action='#'>" %>
 
<center><br><br>
Enter a file description: <input type="text" size=35 name="doctitle"><br><br>
    Select a document: <input type="button" value="Browse..." class="btn" onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'"/><input name="attach1" type="file" size=35 class="hidebrowse" onchange="$('#fileselected').show();">
&nbsp;&nbsp;<span id="fileselected"><img src="../images/checkmark.gif" border="0" height="16" width="16"></span>
<br><br>
 
    <input style="margin-top:4" type=button value="Upload File" onclick="fileuploadverify_events();" class="btn" onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'"/>
    </form>
</center>
 
<%
end function
 
function SaveFiles
    Dim Upload, fileName, fileSize, ks, i, fileKey, fs, f
 
    Set Upload = New FreeASPUpload
 
    Upload.FilesSave uploadsDirLocal, request.querystring("id"), "Event"
 
	' If something fails inside the script, but the exception is handled
	If Err.Number<>0 then Exit function
 
    SaveFiles = ""
    ks = Upload.UploadedFiles.keys
 
 
    if (UBound(ks) <> -1) then
 
'
 
    else
      SaveFiles = "<br>The file you have entered does not appear to be valid or already exists. Please select another file."
    end if
 
 
end function
%>
 
<%
Dim diagnostics
if Request.ServerVariables("REQUEST_METHOD") <> "POST" then
        response.write "<div align=""center"">"
        OutputForm()
        response.write "</div>"
else
    response.write "<div align=""center"">"
    OutputForm()
If Request.QueryString("tabupdated") = 2 Then
    response.write SaveFiles()
%>
<span id="uploading">
      <div align="center"><font size="2" face="Arial, Helvetica, sans-serif"> 
          <image src="../images/indicator.gif" border="0"> <i>Uploading File... Please Wait.</i>
          </font></div>
</span>
<%
End If
    response.write "<br><br></div>"
End If
 
%>
 
</body>
</html>

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-07-03 at 09:53:59ID24542720
Tags

ASP

,

upload

,

filesystemobject

,

permission

,

denied

,

javascript

,

iis

Topics

Active Server Pages (ASP)

,

JavaScript

,

Microsoft IIS Web Server

Participating Experts
1
Points
0
Comments
4

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. ADODB.Stream Permissions?
    I am using the following process to force an Open/Save dialog when someone clicks on a link to a particular file for download. Response.Buffer = True Dim strFileSize Const adTypeBinary = 1 Response.Clear Set objStream = Server.CreateObject("ADODB.Stream") objStr...
  2. ASP ADODB.Stream
    Whenver I go to view this file on my ME computer running IE 6 it redirects me to my login page (even though my session variable is not blank) and downloads my login page to Word. This works fine on one pc running XP and IE 6 but doesn't work on another computer running ME and...
  3. Maximum length for ADODB.Stream?
    I'm using ADODB.Stream to stream a file. Seemingly, I'm able to stream files that are around 350KB or smaller. Also seemingly, I'm not able to transfer files that are over that size ADODB.Stream xml_file.nodeTypedValue I'm getting the error "Microsoft VBScript runt...
  4. Problem to download Large mp3 file (over 4MB) using A…
    Hi, I created a code to download different files (jpg, gif, mp3, wma) from the client's website. I use ADODB.Stream object. I don't have any problems with jpg and gif formats. When I try to download mp3/wma files I get IE msg: IE cannot open this site. I defined that the prob...
  5. File name in ADODB.Stream
    Hi Experts, To offer visitors a download without giving away the path to the file, I implemented the code as described in Microsofts Knowledge Base article "Use of the ADODB.Stream Object to Send Binary Files to the Browser through ASP" (http://support.microsoft.co...
  6. File type in ADODB.Stream
    Hi Experts, To offer visitors a download without giving away the path to the file, I implemented the code as described in Microsofts Knowledge Base article "Use of the ADODB.Stream Object to Send Binary Files to the Browser through ASP" (http://support.microsoft.co...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: cj_1969Posted on 2009-07-06 at 05:34:53ID: 24784529

Welcome to the fun world of MS permissions!
If you are copying the file from one server to another using an ASP file then IIS is using the anonymous account of the web server to execute the code.  This being the case IUSR_<server name> being a local account on the server does not have permissions to any network resources.

THe easiest way to do this is to create a local account on the IIS server and one on the file server with the same name and password (or use a domain account if both machines are members of the same domain) and then grant the account appropriate NTFS and share persmissions on the file server and over ride the anonymous ID for the directory (or you might be able to do it at the file level and do it just for this page) with the ID and PW that you just created.  Then when the page runs it will run under that new ID which should now have permissions to access the remote server and directory.

 

by: MDauphinais1Posted on 2009-07-06 at 07:04:47ID: 24785266

Thanks for the response. But like I said in my post:

"I have a virtual directory set up on IIS pointing to the remote file share. The anonymous permissions are configured for a domain account that has Read/Write/Modify access to the remote file server. "

I am aware of the anonymous user issue on IIS. I already took care of that by using a domain account. The issue I am experiencing is not chronic. If I independently call FileSystemObject to create or move a file to the remote server, it works fine. This tells me the permissions are good. However, if I try to upload to the remove server, I get Permission Denied, Write File Error or a blank response but no upload.

If I upload to the local web server instead, it works fine. Then if I try to call the FileSystemObject for any reason on the remove server, create folder, move file, etc. within a few minutes from when the upload occured I will get Permission Denied, Write File Error, etc. on the remove server. If I literally sit and wait for several minutes after the upload occurs and try the FileSystemObject call again, whatever I was trying to do will run fine.

The upload script is not changing any rights (at least not intentionally) so this is very perplexing.

 

by: cj_1969Posted on 2009-07-06 at 07:29:25ID: 24785518

Sorry for the mis-understanding.
Two things come to mind.
Since you need to access a "remote" network resource make sure that you have impersonation enabled for this directory/site in IIS, otherwise I believe the credentials default to the anonumous machine account, despite what is being used in IIS for anonymous.
The other thing that comes to mind is that it might be trying to use the application pool ID as oppsed to the anonymous account.  You can try changing the logon ID of the app pool to the domain account and see if this works ... I believe you will still need to have impersonation enabled for the site for this to work.

http://msdn.microsoft.com/en-us/library/134ec8tc(VS.80).aspx

 

by: MDauphinais1Posted on 2009-09-14 at 11:03:00ID: 25327798

The issue ended up being on our servers. I don't really know what the issue was but I was told the file share server was screwed up with a failing HDD and other strange issues with the way they have everything set up.

What I did to finally get it working was originally I had the entire IIS site set to Anonymous with credentials that had access on the file share. I changed that to make the entire site Windows Authentication only and made one specific folder Anonymous with the special credentials. This folder only contains one file which creates/deletes folders on the file share. To keep the session variable for the current user from being overridden I call the file in this folder with JavaScript instead of from ASP. Seems to be working so far...

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...