cdoobject.send causes UnauthorizedAccessException

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default cdoobject.send causes UnauthorizedAccessException

    The following code fragment works as part of an page.asp but when I tried it
    under asp.net I get an UnauthorizedAccessException. The text of the error
    message talks about giving ASPUSER write access to a file but I have no idea
    what file needs to get the permission. I tried to find it using filemon but
    to no avail. There's nothing in any of the event logs or the IIS logs
    indicating where the problem might be.

    Can you help? All I want is to send a simple message out without having to
    log into a session or create some exchange account. It was so simple under
    asp; sigh.

    ' next we need to send an email out to Sales

    Dim objMsg As Object

    Dim strFrom, strTo, strSubject, strBody As String

    Dim lngImportance As Int32

    strFrom = "sales@gotnoise.com"

    strTo = "Larry@froghaven.com" ' Trim(Request.Form("Email"))

    strSubject = "Home Comfort Solution's Special Report Access on
    Noise||Shield"

    strBody = "This was a test from the Noise||Shield site."

    lngImportance = 1

    objMsg = Server.CreateObject("CDONTS.NewMail")

    objMsg.Send(strFrom, strTo, strSubject, strBody, lngImportance)

    objMsg = Nothing



    -Larry


    Larry Guest

  2. Similar Questions and Discussions

    1. UnauthorizedAccessException when using COM interop
      Hi, I am currently working on a webservice that is calling functions from a VB6 COM component. the COM is working when called from a regular .NET...
    2. Serer error: System.UnauthorizedAccessException
      I have a web app that works fine in my XP pro developer PC. I moved it to the test server(windows server 2003 standard) with Copy project and when I...
    3. System.UnauthorizedAccessException
      Hello, I'm using this code to access a network share from an asp.net page: Dim dir As DirectoryInfo = New...
    4. UnauthorizedAccessException when creating virtual dir from asp.net
      In c# we have a function that creates a virtual directory in IIS 6.0 using DirectoryServices API. The code looks like this: // log in to IIS...
    5. UnauthorizedAccessException
      ASP.NET application set up as follows: machine.config set to run as "SYSTEM" web.config has impersonate="true", authentication mode="None" IIS...
  3. #2

    Default RE: cdoobject.send causes UnauthorizedAccessException

    Hi Larry,

    Did you use Anonymous access or Windows Integrated authentication? If you
    use Anonymous Access, you may consider following steps:

    1. In machine.config, <ProcessModal> section, change to use SYSTEM account.
    This enable impersonate for the ASP.NET application.
    2. In IIS manager, right click the virtual directory and select
    Properties/Directory Security. In Authentication and Access control, Click
    Edit button, change the Anonymous access acount to a domain user which can
    send email via Exchange server, for example, your current logon account.
    3. In the Web.config of the ASP.NET, add following line:

    <identity impersonate=true />

    After above steps, the ASP.NET appllication will send the email with the
    domain account you set in step 2.

    For more ifnormation about ASP.NET impersonate, you may refer to:

    INFO: Implementing Impersonation in an ASP.NET Application
    [url]http://support.microsoft.com/default.aspx?scid=kb;en-us;Q306158[/url]

    Hope this help,

    Luke
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    [MSFT] Guest

  4. #3

    Default Re: cdoobject.send causes UnauthorizedAccessException

    I have several different asp.net applications and web services on my system,
    would not setting the processmodel account to SYSTEM leave me vulderable to
    hackers, and pose a security problem? There must be a way to allow only this
    one app send emails without exposing account usernames and passwords in the
    code.

    Yes I do want this app to operate under any anonymous access web site. At
    the moment the development site for this app though is accessed using
    windows security. What I'm not clear on is why the ASP behavior works but
    the ASP.NET does not.

    Your suggsestion to set up a new account for anonymous for this site is fine
    but I'm not real savy on what permissions I need to set in the security
    policys (for a Win2k domain controller/web server) to allow ASP.NET apps and
    the email function to work yet still maintain a secure system. Would you
    provide me something that would spell out what needs to be done in this
    area. I've been having some problems getting the permissions and security
    settings set up correctly for ASP web sites to allow anonymous access.

    Also if I do set up this exchange account when the email is sent would it
    not show the sender as being the exchange account or will it use the info
    provided to the CDO object?

    And my last question; I was under the impression that the CDONTS object was
    not dependent on exchange but would use SMTP to send the email. If I add
    this account won't that tie me to a domain having an exchange server?

    -Larry

    "[MSFT]" <lukezhan@online.microsoft.com> wrote in message
    news:bOb62WDIEHA.132@cpmsftngxa06.phx.gbl...
    > Hi Larry,
    >
    > Did you use Anonymous access or Windows Integrated authentication? If you
    > use Anonymous Access, you may consider following steps:
    >
    > 1. In machine.config, <ProcessModal> section, change to use SYSTEM
    account.
    > This enable impersonate for the ASP.NET application.
    > 2. In IIS manager, right click the virtual directory and select
    > Properties/Directory Security. In Authentication and Access control, Click
    > Edit button, change the Anonymous access acount to a domain user which can
    > send email via Exchange server, for example, your current logon account.
    > 3. In the Web.config of the ASP.NET, add following line:
    >
    > <identity impersonate=true />
    >
    > After above steps, the ASP.NET appllication will send the email with the
    > domain account you set in step 2.
    >
    > For more ifnormation about ASP.NET impersonate, you may refer to:
    >
    > INFO: Implementing Impersonation in an ASP.NET Application
    > [url]http://support.microsoft.com/default.aspx?scid=kb;en-us;Q306158[/url]
    >
    > Hope this help,
    >
    > Luke
    > Microsoft Online Support
    >
    > Get Secure! [url]www.microsoft.com/security[/url]
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >

    Larry Guest

  5. #4

    Default Re: cdoobject.send causes UnauthorizedAccessException

    Sorry but this suggestion did not work. In fact it seems to of made it worse
    in that now the customerrors = off setting in the web.config file seems to
    be ignored and I get no diagnostic or trace info; even when trying to view
    the page from the hosting server machine.

    -Larry

    "[MSFT]" <lukezhan@online.microsoft.com> wrote in message
    news:bOb62WDIEHA.132@cpmsftngxa06.phx.gbl...
    > Hi Larry,
    >
    > Did you use Anonymous access or Windows Integrated authentication? If you
    > use Anonymous Access, you may consider following steps:
    >
    > 1. In machine.config, <ProcessModal> section, change to use SYSTEM
    account.
    > This enable impersonate for the ASP.NET application.
    > 2. In IIS manager, right click the virtual directory and select
    > Properties/Directory Security. In Authentication and Access control, Click
    > Edit button, change the Anonymous access acount to a domain user which can
    > send email via Exchange server, for example, your current logon account.
    > 3. In the Web.config of the ASP.NET, add following line:
    >
    > <identity impersonate=true />
    >
    > After above steps, the ASP.NET appllication will send the email with the
    > domain account you set in step 2.
    >
    > For more ifnormation about ASP.NET impersonate, you may refer to:
    >
    > INFO: Implementing Impersonation in an ASP.NET Application
    > [url]http://support.microsoft.com/default.aspx?scid=kb;en-us;Q306158[/url]
    >
    > Hope this help,
    >
    > Luke
    > Microsoft Online Support
    >
    > Get Secure! [url]www.microsoft.com/security[/url]
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >

    Larry Guest

  6. #5

    Default Re: cdoobject.send causes UnauthorizedAccessException

    Hi Larry,

    CDONTS can send and receive messages without requiring Exchange server:

    INFO: What is the Difference Between CDO 1.2 and CDONTS?
    [url]http://support.microsoft.com/default.aspx?scid=kb;en-us;Q177850[/url]

    If you have a smarthost smtp server to work with CDONTS, I suggest you may
    consider system.web.mail instead. It is suggested in a .NET project:

    [url]http://support.microsoft.com/default.aspx?scid=kb;en-us;Q314201[/url]
    HOWTO: Send E-mail Programmatically with System.Web.Mail and Visual Basic
    .NET

    Without exchange,( system.web.mail), the security reqiurement will be a
    little lower. Only ASPNET account is enough. The ASPNET should have
    permission on foll

    HKCR/TypeLib/{CDO....blah}
    C:\Inetpub\mailroot\pickup folder

    For more information on System.web.mail:

    [url]http://weblogs.asp.net/dwanta/archive/2004/01/05/47695.aspx[/url]

    Luke
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    [MSFT] Guest

  7. #6

    Default Re: cdoobject.send causes UnauthorizedAccessException

    Hi Larry,

    How about my suggestion? Did you have any concern on system.web.mail?

    Luke
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    [MSFT] Guest

  8. #7

    Default Re: cdoobject.send causes UnauthorizedAccessException

    sorry I had to be out of town yesterday and today I need to focus on taxes,
    so tomorrow I should get a chance to look at your suggestion. I did BTW get
    your first suggested process to work finally. I had to go back to the
    machine.config file and set the default setting for the customerrors off to
    get any meaningful displayed to show programmer errors, once that was fixed
    your first suggest did in fact work. I'm not sure why the local web.config
    settings wouldn't work, I've been having "that" problem on and off ever
    since I start writing ASP.NET apps.

    I'm a bit nervous about leaving the ASP worker account set to SYSTEM, so I
    will try your the SYSTEM.WEB.MAIL approach. I'll let you know the outcome in
    a few days.

    Thanks for your help.
    -Larry


    "[MSFT]" <lukezhan@online.microsoft.com> wrote in message
    news:S1oqLNgIEHA.3924@cpmsftngxa06.phx.gbl...
    > Hi Larry,
    >
    > How about my suggestion? Did you have any concern on system.web.mail?
    >
    > Luke
    > Microsoft Online Support
    >
    > Get Secure! [url]www.microsoft.com/security[/url]
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >

    Larry Guest

  9. #8

    Default Re: cdoobject.send causes UnauthorizedAccessException

    Hi Larry,

    Thank you for the information.

    Luke
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    [MSFT] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

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