Database SMTP Settings For Password Recovery?

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
1/13/2010 11:06:54 AM
Gravatar
Total Posts 10

Database SMTP Settings For Password Recovery?

I need to configure the "Password Recovery" controls to use the SMTP settings contained in the MP_SITESETTINGSEX  table.  I know the standard answer is that this portal feature is an ASP.NET 2.0 built in control, and therefore must configure with the web.config/system.net settings, but there must be someone out there who has found a way to get Mojo Portal to use the dB settings. 

The only solution I can think of is to replace the line in the web config with a C# filestream update and have the user restart the web server. Unfortunately, this solution is rather awkward and did not sit well with the powers that be. Aslo, if there is an error...there goes your web config.

Can anyone please help?

Many thanks. 

P.S. - I know...I need to buy Joe a beer.

1/13/2010 11:20:02 AM
Gravatar
Total Posts 18439

Re: Database SMTP Settings For Password Recovery?

I do not think it is possible without doing away with the asp.net PasswordRecovery control and using a custom solution.

1/13/2010 12:04:42 PM
Gravatar
Total Posts 10

Re: Database SMTP Settings For Password Recovery?

Thanks Joe,

Thats what I thought, but it was worth a try. I owe you a few beers.

Thanks.

ncphares

1/14/2010 7:59:49 AM
Gravatar
Total Posts 18439

Re: Database SMTP Settings For Password Recovery?

Many Thanks for the beers!

You know it is possible to solve this by implementing a custom PasswordRecover.aspx page in an external project if it is really important. You could use a post build event to copy the custom one up replacing the mojoPortal one.

Cheers,

Joe

1/14/2010 1:39:16 PM
Gravatar
Total Posts 10

Re: Database SMTP Settings For Password Recovery?

Hey Joe,

Yeah, I think that would be best, but we opted to use the webconfigurationmanager class to forward the email (site settings) settings to the system.net section to save time.


Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
System.Net.Configuration.SmtpSection smtpSettings = config.GetSection("system.net/mailSettings/smtp") as System.Net.Configuration.SmtpSection;

blah blah blah, yadda yadda yadda...

config.Save();


This seems to work well and it doesn't require a restart. If we had lots of time we would go for the custom control.

Thanks again for all your help and patience.

ncphares

 

1/14/2010 1:51:40 PM
Gravatar
Total Posts 18439

Re: Database SMTP Settings For Password Recovery?

So why is it that you want to use the settings from the db instead of just putting them in Web.config?

I assumed you were wanting to do that to have different smtp server per site in a multi site installation.

In either case where in the code, at what event do you make these config changes?

Certainly don't want that code to execute very often.

The problems I see with this approach are:

  1. In order for that config.Save() to work, the Web.config must be writable by the web process user which is not a good security strategy.
  2. Whenever the Web.config gets modified it will recycle the application
  3. I'm pretty sure that would not work in Medium Trust and would throw a security exception

Best,

Joe

1/14/2010 6:07:49 PM
Gravatar
Total Posts 10

Re: Database SMTP Settings For Password Recovery?

Yep, once compiled it failed with a permissions error. So I guess we have no choice but to write our own control for this. Probably should have just bit the bullet and done that to begin with.

Again, thanks.

ncphares 

You must sign in to post in the forums. This thread is closed to new posts.