I am getting this error when I try to send via the local server
CDO.Message.1 error '80070005'
Access is denied.
/mail.asp, line xxx
Here is the code I am using
MailBodyText = "TEST"
Set objNewMail = CreateObject("CDO.Message")
objNewMail.To = sSendTo
objNewMail.From = "webmaster#EXAMPLE.com"
objNewMail.Cc = "webmaster#EXAMPLE.com"
objNewMail.Subject = "Information Request & Feedback"
objNewMail.HTMLBody = "The following information was sent from " & sEmail & ":" & "<br>" & CHR(13) & MailBodyText & "<br>copies of this mail we sent to :"& sSendTo
objNewMail.Send
Set objNewMail = Nothing
It looks like it is a permission error at the ISSUR doesn't have write permission to write to the mailroot/pickup folder.
But we have checked that and the services account that this site is using seems to have the rights.
Question is this error always a file permission error?
Question how to know / set the location that CDO is using? So we can confirm the permissions
What else should look at to fix this?
Use the .configuration property which allows for authentication and other fine tuning..
examples at : http://www.paulsadowski.com/wsh/cdo.htm
update
The .configuration property allows to set the pickup directory (as you request)
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:\inetpub\mailroot\pickup"
objNewMail.Configuration.Fields.Update
objNewMail.Send
IF YOU DON'T WANT TO CHANGE YOUR CODE
Grant IIS_IUSRS group write access to c:\inetpub\mailroot\Pickup folder or whatever is your pickup dir.
It must be IIS_IUSRS Group, not the IUSR User (you got it mispelled probably).
I was getting this error after performing steps specified in option 3 at blog.msdn.com
I didn't have to change the ASP code. Your code works fine on my server.
I am migrating some old classic asp sites to a new (windows 2008R2) server and I had "exactly" the same problem (well at least the same error and basically the same code). The solution presented by Gaby:
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
objNewMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:\inetpub\mailroot\pickup"
did not work for me, i still had the same error.
After some searching i found this suggestion:
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
(do NOT set the smtpserverpickupdirectory)
Now it works fine.
By the way if you need to set up the necessary SMTP service on Windows 2008 server (IIS7), I found this blog extremely helpfull.
UPDATE:
According to microsoft sendusing = 1 uses the SMTP server and sendusing 2 uses Outlook Express, I've looked on the server, and there doesn't seem to be outlookexpress or windows mail installed, still this setting workes for me. If anyone could explain that I'm curious to know.
Related
I keep getting permission denied when trying to open the second file here for writing. I know the first file opens fine as I can write it out to the screen and I have set write permissions for users. Is this so simple that I'm being blinded by it???
css_org = server.MapPath("style.css")
css_new = server.MapPath("new_style.css")
Set fso = CreateObject("Scripting.FileSystemObject")
Const ForReading = 1
Const ForWriting = 2
Set objFile1 = fso.OpenTextFile (css_org, ForReading)
Set objFile2 = fso.OpenTextFile (css_new, ForWriting, True) ' 500 error on this line
Your code seems to be ASP, so you need to grant write permission to the user running the code (usually the service account running IIS), not the user who is logged into your web application.
Have you tried writing to the file outside of code to see if the user context can write to it? It's probably not an issue with your code. You may get a more informative error message if you try to write to it, say, with Notepad. Also, you could try using SysInternals' "Process Explorer" -- their "Find Handle" feature to test that file to see if there is some process locking it.
I have a classic asp email script that uses authenticated CDOSYS to send to emails from a database. It's running on a Parallels Plesk Windows 2008 server.
This works fine for all email addresses except for any addresses that belong to sites on the server I am sending from.
I could authenticate using a Google Apps email account (the domain is set up using Google Apps for email) BUT I would run up against Google' 24 hour sending limits each time the client ran the script.
Can anyone point out where I'm going wrong or explain why email to sites on the sending server causes an error? The error is
error '8004020f'
/admin/send-group-email.asp, line 128
which is the objCDO.Send line
The Code :
(primarydomain.com is the domain name of the primary account the site lives under in Parallels. The SenderEmail value would be, for example, id#secondarydomain.com)
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "localhost"
.Item(cdoSMTPAuthenticate) = 1
.Item(cdoSendUsername) = "authenticate#primarydomain.com"
.Item(cdoSendPassword) = "thepassword"
.Update
End With
while (NOT RS_Emails.EOF)
Dim objCDO
set objCDO = Server.CreateObject("CDO.Message")
objCDO.Configuration = cdoConfig
objCDO.From = CStr(Request.Form("SenderEmail")) & " (" & CStr(Request.Form("SenderName")) & ")"
objCDO.To = RS_Emails.Fields.Item("email").Value
objCDO.Subject = CStr(Request.Form("Subject"))
objCDO.HTMLBody = message
objCDO.Send
set objCDO = Nothing
RS_Emails.MoveNext
Wend
set cdoConfig=Nothing
This is most likely a server issues which can be solved with Plesk.
Please look at the following link:
http://mkb-training.com/index.php?option=com_content&view=article&id=1:setting-up-google-apps-with-plesk&catid=1:google-tutorial&Itemid=2
Pay attention to the following:
"Uncheck the MX1: "Domain IP also used for mail server"" (there are screenshots there on how to do this). I am not 100% sure about Plesk, but in H-Sphere (another Parallels control panel) doing this is essential for being able to send from the server to your own domain when you have a remote mail exchanger.
Also make sure that no MX records point to your server (even if the Google Apps ones are configured correctly).
I have a Web Handler that I'm using to read a file and then stream it out to the client. This works fine if i use the file path on the local drive:
D:\Path\To\My\File.flv
If I use a sharename, however:
\ServerName\ShareName\File.flv
I get a "Logon failure: unknown user name or bad password."
The share is open to everyone, full control.
I have impersonation enabled and have the following in my handler:
context.Response.Write("Context User: " + ((WindowsIdentity)context.User.Identity).Name + "<br />");
context.Response.Write("Windows Identity: " + WindowsIdentity.GetCurrent().Name + "<br />");
When I configure the IIS application to run as with anonymous access using a specific account, I get the following
Context User:
Windows Identity: SpecificAccount
When I configure IIS to not use anonymous access, but use windows authentication, I get
Context User: MyAccount
Windows Identity: MyAccount
It does not change the error message for the share vs nonshare.
I find this webpage regarding Web Handlers and impersonation:
http://weblogs.asp.net/drnetjes/archive/2005/06/06/410508.aspx
but, I'm not exactly sure how to implement that, or, if it would even solve the issue.
Any ideas?
In your above post, it's simple, but you put \ServerName\ShareName\File.flv
shouldn't it be \\ServerName\ShareName\File.flv
worst case, you can use file://ServerName/ShareName/File.flv, but note that for local files you should use the shorthand file:///C:/path/File.flv. (see wikipedia)
Gaah... I hate answering my own questions, but here's what the problem was:
The share and file permissions were set properly. This is an old windows 2003 machine and when I use a new application pool (which I did with this particular application), I always have a problem with permissions.
The solutions was (facepalm) reboot the server.
I'm sorry for all the braincells that the 60 some odd people wasted on this.
Thanks again for all your help.
Stupid IIS... Stupid Windows 2003... must rebuild server someday
Issue
Msxml2.ServerXMLHTTP keeps returning 401 - Unauthorised errors each time we attempt to read the contents of a file (ASP) from a web server.
Source server is running IIS6, using NTLM integrated login.
This process has been used successfully before, but only in as far as extracting XML files from external websites, not internal ones.
The proxy settings in the registry of the server on which the script is run has also been updated to bypass the website in question, but to no avail.
All paths identified in the VBScript have been checked and tested, and are correct.
User running the script has correct read/write permissions for all locations referenced in the script.
Solution needed
To identify the cause of the HTTP 401 Unauthorised messages, so that the script will work as intended.
Description
Our organisation operates an intranet, where the content is replicated to servers at each of our remote sites. This ensures these sites have continued fast access to important information, documentation and data, even in the event of losing connectivity.
We are in the middle of improving the listing and management of Forms (those pesky pieces of paper that have to be filled in for specific tasks). This involves establising a database of all our forms.
However, as the organisation hasn't been smart enough to invest in MSSQL Server instances at each site, replication of the database and accessing it from the local SQL server isn't an option.
To work around this, I have constructed a series of views (ASP pages) which display the required data. I then intend to use Msxml2.ServerXMLHTTP by VBScript, so I can read the resulting pages and save the output to a static file back on the server.
From there, the existing replication process can stream these files out to the site - with users having no idea that they're looking at a static page that just happened to be generated from database output.
Code
' Forms - Static Page Generator
' Implimented 2011-02-15 by Michael Harris
' Purpose: To download the contents of a page, and save that page to a static file.
' Target category: 1 (Contracts)
' Target Page:
' http://sharename.fpc.wa.gov.au/corporate/forms/generator/index.asp
' Target path: \\servername\sharename\corporate\forms\index.asp
' Resulting URL: http://sharename.fpc.wa.gov.au/corporate/forms/index.asp
' Remove read only
' Remove read only flag on file if present to allow editing
' If file has been set to read only by automated process, turn off read only
Const READ_ONLY = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("\\server\sharename\corporate\forms\index.asp")
If objFile.Attributes AND READ_ONLY Then
objFile.Attributes = objFile.Attributes XOR READ_ONLY
End If
Dim webObj, strURL
Set webObj = CreateObject("Msxml2.ServerXMLHTTP")
strURL = "http://sharename.fpc.wa.gov.au/corporate/forms/generator/index.asp"
webObj.Open "GET", strURL
webObj.send
If webObj.Status=200 Then
Set objFso = CreateObject("Scripting.FileSystemObject")
Set txtFile = objFso.OpenTextFile("file:\\servername.fpc.wa.gov.au\sharename\corporate\forms\index.asp", 2, True)
txtFile.WriteLine webObj.responseText
txtFile.close
ElseIf webObj.Status >= 400 And webObj.Status <= 599 Then
MsgBox "Error Occurred : " & webObj.Status & " - " & webObj.statusText
Else
MsgBox webObj.ResponseText
End If
Replace your line:
webObj.Open "GET", strURL
With:
webObj.Open "GET", strURL, False, "username", "password"
In most cases 401 Unauthorized means you haven't supplied credentials. Also you should specifiy False to indicate you don't want async mode.
It sounds like the O.P. got this working with the correct proxy settings in the registry (http://support.microsoft.com/kb/291008 explains why proxy configuration will fix this). Newer versions of ServerXMLHTTP have a setProxy method that can be used to set the necessary proxy configuration in your code instead.
In the O.P. code above, after webObj is created, the following line of code would set up the proxy correctly:
webObj.setProxy 2, "0.0.0.0:80", "*.fpc.wa.gov.au"
ServerXMLHTTP will pass on the credentials of the user running the code if it is configured with a proxy, and if the target URL bypasses that proxy. Since you are bypassing the proxy anyway, you can make it a dummy value "0.0.0.0:80", and make sure your target url is covered by what you specify in the bypass list "*.fpc.wa.gov.au"
I would first test if you can reach your url through a normal browser on the same server X you run your code on (A). I would try then reach the url from another PC. One never used to reach that url but in the same network as server X (B).
If B works but A doesn't I would suspect that for some reason your source server (i.e. that one that serves the url) blocks server X for some reason. Check the security settings of II6 and of NTLM.
If both A and B don't work, there is something wrong more in general with your source server (i.e. it blocks everything or NTML doesn't allow you in).
If A works (B doesn't matter then), the problem has to be somewhere in your code. In that case, I would recommend fiddler. This tool can give you the HTTP requests of both your browser and your code in realtime. You can then compare both. That should give you at least a very strong hint about (if not immediately give you) the solution.
I have a Windows 2003 server running IIS 6 and have some scripts that do automated setup and creation of websites. They are not working on a new server I cam commissioning (they already work happily on 3 other W2K3 servers). The problem appear to boil down to WMI security on the IIS provider. The ASP code below represents the problem (although it is not the original code that causes the problem - this is a simplified demonstration of the problem).
Set wmiProvider = GetObject("winmgmts:\\.\root\MicrosoftIISv2")
If wmiProvider is Nothing Then
Response.Write "Failed to get WMI provider MicrosoftIISv2<br>"
End If
Response.Write "Querying for IISWebService...<br>"
Set colItems = wmiProvider.ExecQuery("Select * From IISWebServer",,0)
Response.Write "Error: " & Hex(Err.Number) & " (" & Err.Description & ")<br>"
If I run this in my browser, I get an access denied error reported after the ExecQuery call. I have set WMI access for the IUSR_ user from the Root branch all the way down. In fact, I can query for IP address information using the CIMV2 provider quite happily. If I put the IUSR user in the machine admins group it all works, but I don't really want to do that.
This must be a DCOM/WMI security problem, but I can't work out what else there is. Can anyone shed any light?
After reading G. Stoynev's comment asking if any events were logged in the Windows Logs, I checked the event logs on the server to which I'm attempting to access IIS remotely via WMI, and lo and behold I found an event with the following text:
Access to the root\WebAdministration namespace was denied because the namespace is marked with RequiresEncryption but the script or application attempted to connect to this namespace with an authentication level below Pkt_Privacy. Change the authentication level to Pkt_Privacy and run the script or application again.
See the code in this answer to the related SO question c# - "Access is denied" Exception with WMI.
Here's some example C# code that I added that seemed to resolve this issue for me:
ConnectionOptions options = new ConnectionOptions();
options.Authentication = AuthenticationLevel.PacketPrivacy;
ManagementScope managementScope = new ManagementScope(#"\\remote-server\root\WebAdministration", options);
// ...
If this is something that you intend to run as a tool for yourself or your admin (as opposed to the unwashed anonymous masses), here is a way I have used in the past (YMMV):
Set up a new directory in your website (e.g. /SiteCreate) and place your WMI scripts there
Configure a Windows user that has appropriate rights (probably admin in this case but you should use whatever is pertinent to your app)
Turn off the anonymous access to the directory you created in step 1 and then set the security to allow access only to the user you created in step 2 (turn on the authentication for that directory)
Now, when you navigate to that directory in your browser, you should get a login prompt. When you enter the username/password you created in step 2 your script will have the appropriate rights to perform your WMI requests.
Not a DCOM issue, more so a WMI security and encryption issue. Try changing the GetObject moniker to include impersonation and pktPrivacy, eg:
Set wmiProvider = GetObject("winmgmts:{impersonationLevel=impersonate;authenticationLevel=pktPrivacy}!\root\MicrosoftIISv2")
Refer to the follow MS article for more info:
http://msdn.microsoft.com/en-us/library/aa393618(v=vs.85).aspx