Saturday, March 24, 2012

smtpauthenticate & ASPNET_SETREG

Hi,
I'm working on an ASP.NET intranet site which is still in v1.1 of the
Framework. We are using ASPNET_SETREG to impersonate a domain user for
various reasons, as follows:
<identity impersonate="true"
userName=" registry:HKLM\SOFTWARE\Intranet\identity
\ASPNET_SETREG,userName"
password=" registry:HKLM\SOFTWARE\Intranet\identity
\ASPNET_SETREG,password"
/>
Works perfectly.
However, we now have a requirement to get the site to send external email.
When I first tried this, I got the "Unable to relay..." CDO message. Looking
this up on www.systemwebmail led me to add the following to the SendMail
code:
objMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthen
ticate",
"1");
objMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/senduserna
me",
"<userid>");
objMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpasswo
rd",
"<password>");
SmtpMail.SmtpServer = "<mailserver>";
SmtpMail.Send(objMsg);
That now allows the site to send external mail, which is fine so long as I
hard-code the username and password into the above code.
Is there anyway that I can combine the two i.e. get the CDO fields from the
registry in the same way as ASP.NET does when implementing the
impersonation?
Any assistance gratefully received.
Best,
MarkNo-one got any ideas...?
"Mark Rae" <mark@.mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:%23n1Sc0N9FHA.2676@.TK2MSFTNGP15.phx.gbl...
> Hi,
> I'm working on an ASP.NET intranet site which is still in v1.1 of the
> Framework. We are using ASPNET_SETREG to impersonate a domain user for
> various reasons, as follows:
> <identity impersonate="true"
> userName=" registry:HKLM\SOFTWARE\Intranet\identity
\ASPNET_SETREG,userName"
> password=" registry:HKLM\SOFTWARE\Intranet\identity
\ASPNET_SETREG,password"
> />
> Works perfectly.
> However, we now have a requirement to get the site to send external email.
> When I first tried this, I got the "Unable to relay..." CDO message.
> Looking this up on www.systemwebmail led me to add the following to the
> sendmail code:
>
> objMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauth
enticate",
> "1");
> objMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/senduser
name",
> "<userid>");
> objMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpass
word",
> "<password>");
> SmtpMail.SmtpServer = "<mailserver>";
> SmtpMail.Send(objMsg);
> That now allows the site to send external mail, which is fine so long as I
> hard-code the username and password into the above code.
> Is there anyway that I can combine the two i.e. get the CDO fields from
> the registry in the same way as ASP.NET does when implementing the
> impersonation?
> Any assistance gratefully received.
> Best,
> Mark
>

0 comments:

Post a Comment