Discussion:
FileSystemObject problem in classic ASP
(too old to reply)
billy
2008-03-31 13:56:10 UTC
Permalink
i'm good at administrative .vbs and .hta, but very weak on .asp. i
hope you can help.

so i have a web server configured to use "intigrated windows
authentication" (anonymous disabled) and asp code that should check
for a file, link to it, and list the modified date. here is a snippet:

strPCBPath = "./Users/" & Replace(LOGON_USER, "DOMAIN\", "")
If objFSO.FileExists(strPCBPath & ".html") Then _
strHTML = strHTML & vbcrlf & "<tr><td><a href=""" &
strPCBPath _
& ".html"">View Inventory</a></td>" & vbcrlf & "<td>" _
& objFSO.GetFile(strPCBPath & ".html").DateLastModified & "</
td></tr>"

my problem is that with this code as listed, the "If" statement always
answers false. If i remove the "If" statement alone, i get "Microsoft
VBScript runtime error '800a0035' File Not Found", but if i then also
remove the the "DateLastModified" statement, clicking on the link
loads the desired page.

strPCBPath = "./Users/" & Replace(LOGON_USER, "DOMAIN\", "")
strHTML = strHTML & vbcrlf & "<tr><td><a href=""" &
strPCBPath _
& ".html"">View Inventory</a></td>" & vbcrlf & "<td></td></
tr>"

it seems to me like the script is running under a different context
than the authenticated user and cannot verify the existance of the
file or get the date. the linked files do not have standard access
rights on them, so i wonder if that is part of the problem (the
authenticated user does have "modify"). but changing the security so
that "everyone" has read access doesn't help. i need to verify the
file existance and get the DateLastModified info. your help would be
appriciated.
Bob Barrows [MVP]
2008-03-31 14:50:53 UTC
Permalink
Post by billy
i'm good at administrative .vbs and .hta, but very weak on .asp. i
hope you can help.
so i have a web server configured to use "intigrated windows
authentication" (anonymous disabled) and asp code that should check
strPCBPath = "./Users/" & Replace(LOGON_USER, "DOMAIN\", "")
If objFSO.FileExists(strPCBPath & ".html") Then _
strHTML = strHTML & vbcrlf & "<tr><td><a href=""" &
strPCBPath _
& ".html"">View Inventory</a></td>" & vbcrlf & "<td>" _
& objFSO.GetFile(strPCBPath & ".html").DateLastModified &
"</ td></tr>"
my problem is that with this code as listed, the "If" statement always
answers false. If i remove the "If" statement alone, i get "Microsoft
VBScript runtime error '800a0035' File Not Found", but if i then also
remove the the "DateLastModified" statement, clicking on the link
loads the desired page.
strPCBPath = "./Users/" & Replace(LOGON_USER, "DOMAIN\", "")
strHTML = strHTML & vbcrlf & "<tr><td><a href=""" &
strPCBPath _
& ".html"">View Inventory</a></td>" & vbcrlf & "<td></td></
tr>"
it seems to me like the script is running under a different context
than the authenticated user and cannot verify the existance of the
file or get the date. the linked files do not have standard access
rights on them, so i wonder if that is part of the problem (the
authenticated user does have "modify"). but changing the security so
that "everyone" has read access doesn't help. i need to verify the
file existance and get the DateLastModified info. your help would be
appriciated.
Have you verified that LOGON_USER contains the correct value? If you do
not have Anonymous disabled, LOGON_USER will be blank. Use
Response.Write to check it.
Response.Write "LOGON_USER contains'" & _
Request.ServerVariables("LOGON_USER") & "'<BR>"
Response.Write "strPCBPath contains '" & strPCBPath & "'"

If LOGON_USER is not blank, then the code is running under the context
of the authenticated user. That user needs permissions for that Users
folder in order to see anything in it.
If permissions are lacking, then fso will not find the file.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
billy
2008-03-31 19:01:46 UTC
Permalink
Post by Bob Barrows [MVP]
Post by billy
i'm good at administrative .vbs and .hta, but very weak on .asp. i
hope you can help.
so i have a web server configured to use "intigrated windows
authentication" (anonymous disabled) and asp code that should check
        strPCBPath = "./Users/" & Replace(LOGON_USER, "DOMAIN\", "")
        If objFSO.FileExists(strPCBPath & ".html") Then _
          strHTML = strHTML & vbcrlf & "<tr><td><a href=""" &
strPCBPath _
          & ".html"">View Inventory</a></td>" & vbcrlf & "<td>" _
          & objFSO.GetFile(strPCBPath & ".html").DateLastModified &
"</ td></tr>"
my problem is that with this code as listed, the "If" statement always
answers false. If i remove the "If" statement alone, i get "Microsoft
VBScript runtime error '800a0035' File Not Found", but if i then also
remove the the "DateLastModified" statement, clicking on the link
loads the desired page.
        strPCBPath = "./Users/" & Replace(LOGON_USER, "DOMAIN\", "")
          strHTML = strHTML & vbcrlf & "<tr><td><a href=""" &
strPCBPath _
          & ".html"">View Inventory</a></td>" & vbcrlf & "<td></td></
tr>"
it seems to me like the script is running under a different context
than the authenticated user and cannot verify the existance of the
file or get the date. the linked files do not have standard access
rights on them, so i wonder if that is part of the problem (the
authenticated user does have "modify"). but changing the security so
that "everyone" has read access doesn't help. i need to verify the
file existance and get the DateLastModified info. your help would be
appriciated.
Have you verified that LOGON_USER contains the correct value? If you do
not have Anonymous disabled, LOGON_USER will be blank. Use
Response.Write to check it.
Response.Write "LOGON_USER contains'" & _
Request.ServerVariables("LOGON_USER") & "'<BR>"
Response.Write "strPCBPath contains '" & strPCBPath  & "'"
If LOGON_USER is not blank, then the code is running under the context
of the authenticated user. That user needs permissions for that Users
folder in order to see anything in it.
If permissions are lacking, then fso will not find the file.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.- Hide quoted text -
- Show quoted text -
Response.Write reports the expected values for LOGON_USER and
strPCBPath
I am able to \\<server>\<share>\<navigate> to the folder and verify
content and modify dates using the same account that i am testing
with. i even tried granting "Everyone" full access to the folder.

still no luck.
billy
2008-03-31 20:44:02 UTC
Permalink
Post by billy
Post by Bob Barrows [MVP]
Post by billy
i'm good at administrative .vbs and .hta, but very weak on .asp. i
hope you can help.
so i have a web server configured to use "intigrated windows
authentication" (anonymous disabled) and asp code that should check
        strPCBPath = "./Users/" & Replace(LOGON_USER, "DOMAIN\", "")
        If objFSO.FileExists(strPCBPath & ".html") Then _
          strHTML = strHTML & vbcrlf & "<tr><td><a href=""" &
strPCBPath _
          & ".html"">View Inventory</a></td>" & vbcrlf & "<td>" _
          & objFSO.GetFile(strPCBPath & ".html").DateLastModified &
"</ td></tr>"
my problem is that with this code as listed, the "If" statement always
answers false. If i remove the "If" statement alone, i get "Microsoft
VBScript runtime error '800a0035' File Not Found", but if i then also
remove the the "DateLastModified" statement, clicking on the link
loads the desired page.
        strPCBPath = "./Users/" & Replace(LOGON_USER, "DOMAIN\", "")
          strHTML = strHTML & vbcrlf & "<tr><td><a href=""" &
strPCBPath _
          & ".html"">View Inventory</a></td>" & vbcrlf & "<td></td></
tr>"
it seems to me like the script is running under a different context
than the authenticated user and cannot verify the existance of the
file or get the date. the linked files do not have standard access
rights on them, so i wonder if that is part of the problem (the
authenticated user does have "modify"). but changing the security so
that "everyone" has read access doesn't help. i need to verify the
file existance and get the DateLastModified info. your help would be
appriciated.
Have you verified that LOGON_USER contains the correct value? If you do
not have Anonymous disabled, LOGON_USER will be blank. Use
Response.Write to check it.
Response.Write "LOGON_USER contains'" & _
Request.ServerVariables("LOGON_USER") & "'<BR>"
Response.Write "strPCBPath contains '" & strPCBPath  & "'"
If LOGON_USER is not blank, then the code is running under the context
of the authenticated user. That user needs permissions for that Users
folder in order to see anything in it.
If permissions are lacking, then fso will not find the file.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.- Hide quoted text -
- Show quoted text -
Response.Write reports the expected values for LOGON_USER and
strPCBPath
I am able to \\<server>\<share>\<navigate> to the folder and verify
content and modify dates using the same account that i am testing
with. i even tried granting "Everyone" full access to the folder.
still no luck.- Hide quoted text -
- Show quoted text -
*** New Information ***

i can load the whole folder into a files collection and enumerate
through them and get the desired results. but i can't seem to get the
FSO FileExists or GetFile methods to work.

FSO FolderExists and GetFolder works perfectly fine just 10 lines
above this.
Bob Barrows [MVP]
2008-03-31 21:17:21 UTC
Permalink
Post by billy
Post by billy
strPCBPath = "./Users/" & Replace(LOGON_USER, "DOMAIN\", "")
If objFSO.FileExists(strPCBPath & ".html") Then _
strHTML = strHTML & vbcrlf & "<tr><td><a href=""" &
strPCBPath _
& ".html"">View Inventory</a></td>" & vbcrlf & "<td>" _
& objFSO.GetFile(strPCBPath & ".html").DateLastModified &
"</ td></tr>"
*** New Information ***
i can load the whole folder into a files collection and enumerate
through them and get the desired results. but i can't seem to get the
FSO FileExists or GetFile methods to work.
FSO FolderExists and GetFolder works perfectly fine just 10 lines
above this.
Hmm, that does seem strange. I will need to try and duplicate this on my
system. I can't do it today but will try to remember to look at it
tomorrow.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
billy
2008-03-31 21:25:04 UTC
Permalink
Post by Bob Barrows [MVP]
Post by billy
Post by billy
strPCBPath = "./Users/" & Replace(LOGON_USER, "DOMAIN\", "")
If objFSO.FileExists(strPCBPath & ".html") Then _
strHTML = strHTML & vbcrlf & "<tr><td><a href=""" &
strPCBPath _
& ".html"">View Inventory</a></td>" & vbcrlf & "<td>" _
& objFSO.GetFile(strPCBPath & ".html").DateLastModified &
"</ td></tr>"
*** New Information ***
i can load the whole folder into a files collection and enumerate
through them and get the desired results. but i can't seem to get the
FSO FileExists or GetFile methods to work.
FSO FolderExists and GetFolder works perfectly fine just 10 lines
above this.
Hmm, that does seem strange. I will need to try and duplicate this on my
system. I can't do it today but will try to remember to look at it
tomorrow.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.- Hide quoted text -
- Show quoted text -
I worked it out.
it was due to inadiquate use of Server.MapPath

Loading...