Tech Talk

Permanent link to Permission denied sending mail using CDONTS Permission denied sending mail using CDONTS

Monday, October 28, 2002

I use the CDONTS object to easily send SMTP messages through my Exchange server in all sorts of web pages. I recently upgraded to Exchange 2000, and applied SP3, and all of a sudden coudn't send anymore. This one took a little digging, so here's the solution for reference.

The permission denied issue has been around a long time with Exchange 5.5, and usually it was a folder permissions issue:

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q228465

However, I'm not using Exchange 5.5, I'm using 2000, and besides, all the permission are correct.

So, it turns out it's actually an SP3 issue, not really Exchange 2000. In SP3, Microsoft removed the general ability to be able to read some IIS metabase settings, requiring the administrator to specifically grant access to the specific user to the specific item needed.

Here's basically what's needed. First, the following script (copy and paste into a MbaAdd.VBS file on your machine), then run it as such:

MbaAdd.vbs <ComputerName>\<AccountName>

    Option explicit
    Dim objSMTP, objInst, objSD, objACL, objACE, objNew
    Dim sAccount

    sAccount = wscript.arguments(0)
    wscript.echo "Updating SMTP service instances..."
    Set objSMTP = GetObject("IIS://LOCALHOST/SMTPSVC")

    For Each objInst In objSMTP
       If objInst.class = "IIsSmtpServer" Then
          wscript.echo objInst.ADSPath
          set objSD = objInst.AdminACL
          set objACL = objSD.DiscretionaryACL
          set objNew = CreateObject("AccessControlEntry")
          objNew.AccessMask = 9 ' read + enumerate
          objNew.AceType = 0 ' ADS_ACETYPE_ACCESS_ALLOWED
          objNew.AceFlags = 2 ' ADS_ACEFLAG_INHERIT_ACE
          objNew.Trustee = sAccount

          objACL.AddAce objNew
          objSD.DiscretionaryACL = objACL
          objInst.Put "adminACL", Array(objSD)
          objInst.SetInfo
       End If
    Next

Refer to http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q324037 for more information.

37 Comments

LaRocque Family