How to authenticate users from an existing db into Nearforums site

There are 3 methods to authenticate users from an existing repository or database into a Nearforums site.

ASP.NET Membership

If your website uses ASP.NET Membership, you can configure the same membership provider in the web.config file of the Nearforums site.
This method will avoid the need for explicit user log on actions (logging on mainsite will also log into Nearforums site). Remember to use the same machine key if you are using 2 different IIS websites.

Custom database authentication

If the database of your main site is accessible through a network connection, from the Nearforums site you can set up a custom db authentication provider.
To do so, create a procedure in your main db following this instructions.
Once you created it, add a new connection string pointing to your db (do not remove the connection string named "Forums"), in the web.config file located in the root folder of your Nearforums site. For example:
<add name="MainDb" connectionString="Data Source=YourDbServer;Initial Catalog=MainDb;User ID=sa;Password=12345678" providerName="System.Data.SqlClient"/>
Then, edit the element custom inside authenticationProviders on the Site.config file located in the folder Config. For example:
<customDb
connectionStringName="MainDb"
storedProcedure="SPNearforumsAuthenticateUser"
registerUrl="http://yourmainsite.com/register/"
forgotPasswordUrl="http://yourmainsite.com/forgot-password/"
allowChangeEmail="false"
accountEditUrl="http://yourmainsite.com/account/"/>

OpenId webring

This feature is useful for websites that already have a user repository, host a main site in another domain or subdomain (ex: www.mainsite.com and forum.mainsite.com) and you can't expose the repository to Nearforums by other methods.
It requires extra development work in your main site.
To enable this functionality, you must expose a OpenId Service Provider from your main site. If you are using .net in your main site, you can do it easily using Dotnetopenauth.
Once you create it, copy the url of the service provider to the element ssoOpenid in the configuration file Site.config, located in the folder <... site root...>/Config/Site.config.

Last edited Sep 4, 2012 at 2:08 PM by jorgebg, version 7

Comments

MediumSA Nov 14 at 2:10 PM 
Hi

This works perfectly, thanks.

I'd just like to take it a step further and avoid repeating the login for members who have already logged in to the main site that is using the Nearforums discussion forum to discuss issues from the main site in the separate discussion forum site. The main site is also an MVC site (v4 C#) with VS2012 & Framework 4.5 - but I'm using a custom authentication system. I'd therefore just like to pass the already authenticated login details to the Nearforums site in the link to the site in the main site's menu - but I haven't so far figured out what I should be sending. Could you possibly help a dumb newbie with the correct syntax that would be required, please?

Alan Holm

holma@dwa.gov.za

PetrAlexeev Nov 28, 2012 at 4:53 PM 
Examples of some popular OpenID Service Providers identifiers that can be used in the ssoOpeid element in the configuration file:
* http://jorgebg.myopenid.com - for myOpenID
* https://www.google.com/accounts/o8/id - for Google
* http://openid.yandex.ru - for Yandex
* http://vkontakteid.ru" - for Vkontakte

It is possible to try, e.g., Google OpenId webring, by using the following setting:
<ssoOpenid identifier="https://www.google.com/accounts/o8/id" />

Some additional information can be found here: http://nearforums.codeplex.com/discussions/281612.