Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Microsoft VBScript runtime error '800a0046' Permission denied 2

Status
Not open for further replies.

patrickdrd

Programmer
Nov 21, 2003
149
0
0
GR
Hi guys! I am writing an asp page in order to access a text file on a server, like this:

myPath = "\\ServerName\log"
LogFile = myYear & myMonth & myDay & ".log"
LogFile = myPath & "\" & LogFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTXT = objFSO.OpenTextFile(LogFile)

My problem is that I get permission denied message when trying to access it. In fact, this server does need a password, but I do not know how to set it, e.g. how can I access a server by typing username and password in the command prompt?
I can access this file though if I copy it to the and use:
Set objTXT = objFSO.OpenTextFile(server.MapPath(LogFile))
Thanks in advance!
 
patrickdrd,

I am a little confused on your purpose. If I could get a little more info, maybe might be able to help.

"writing an asp page in order to access a text file on a server"

From this can we assume the .asp page is on the server where the text file is located?

Can we assume that if you go to the server where the log file is, that it in fact does have the entries in it you would expect?

Can we assume that your intent is to display the contents of the text file in your .asp file on your web server so that you or your users can view the information?

Or is your text log file located on ANOTHER server and as such needs you to map a drive to that system to access that file from the web server?

Get us these answers, and will see if we can help you out. Won't promise there won't be more questions.

DougCranston
 
Do IUSR or IWAM have access to that directory? check the security setting of the directory you're trying to access and give IUSER and/or IWAM Read access. That might help.


--------------------------------------------------
- better than toast.
Penguins - better than --------------------------------------------------
 
Reply to dougcranston: The text (log) file is on another server, which I can access from the network (My Network Places) with Windows authentication (I need to type password), but I cannot access that from my asp page (I get that permission denied message). I have accessed that network folder before though with Visual Basic, without having to map that folder (sth like: \\servername\log\mylogfile.log), but I cannot find out why do I get that message in asp. I'll try mapping that drive and see If it works.
Reply to ChainsawJoe: I do not think that this will work pal, because I am trying to access a network folder (another server). How can I set my own user access to another server?
 
Well i knw your problem and can be fixed.
You try to access an shared file with FSO, that wont gonna work.
Use an work around.
Code:
set ws=Server.CreateObject("WScript.Network.1")
'map share on one free leter drive
ws.MapNetworkDrive "Z:","\\server\share",true,usernamehere,pwdhere
'use fso on drive z

'remove the drive map
ws.RemoveNetworkDrive "Z:",true,true

________
George, M
 
Reply to shaddow: Unfortunately, it didn't work. I am getting the message: "WSHNetwork.MapNetworkDrive error '80070520', A specified logon session does not exist. It may already have been terminated.
/ReadLog.asp, line 128 "
Line 128 is ws.MapNetworkDrive "Z:","\\myServer\myShare",true,
myUserName,myPassWord
Does anyone know why I can't connect and map this drive?
 
Ok, It worked! It just needed myServer\otherserverusername
instead of just username!
Thanks very - very much pal!
How do I disconnect at the end of a session?
I guess, global.asa...
 
When you remove the Network path the bUpdateProfile boolean value should disconect you imediately.

RemoveNetworkDrive(strName, [bForce], [bUpdateProfile]) --
ws.RemoveNetworkDrive "Z:",true,true

________
George, M
 
No, I don't think that you understood my question, which was when is the right time to map the network drive and then remove it? My asp page has sessions and I think that it wouldn't be a good idea to map it and remove it in every session (someone already connected would not be able to view my page by refreshing it for example).
 
Is there a way to write to a file on a network share drive (like \\ServerName\ShareName\FileName.txt) without using MapNetworkDrive? Anonymous users will be accessing my site and I won't know the which letter drives they have used or not used. I don't want to re-map their already mapped drive! :)
I appreciate your help.
Thank you,
Peggy
 
Put this code on a separate file:

Set ws = Server.CreateObject("WScript.Network")
'map share on one free leter drive
ws.MapNetworkDrive "T:", "\\ServerName\ShareName", true, "WebServerName\UserName", strPassWord

and run this separate .asp file once, after the server has started.

Then all users will be able to use the same Mapping I suppose (haven't tested that). Otherwise, you could you the other server's IP address to access the file. For example:

\\127.0.0.1\ShareName\FileName.txt

Good Luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top