Welcome Guest! To enable all features please Login or Register.
Options
View
Go to last post Go to first unread
Offline becometechmad  
#1 Posted : 26 May 2014 19:19:32(UTC)
becometechmad


Rank: YAF Forumling

Reputation:

Joined: 26/05/2014(UTC)
Posts: 1

Dear Friends,
I just started digging into Yet another forum. I have come across following scenario. I would appreciate if anyone can help me towards the right approach.
I have 2 sites web.mysite.com and forum.mysite.com. Both of them are installed in different web server and are running successfully with their own user management and login mechanism.
web.mysite.com
======================
This is created using MVC3 and has its own authentication mechanism with SQL server database
Login==> Login mechanism leveraging Entity framework with simple DB call to validate user’s credential and creating forms authentication cookie instead.
User Registration==> Simple Db call with Entity framework to create a user in database.

Note: No where I am using ASP.Net membership provider.

forum.mysite.com
======================
Installed the latest version from yetanotherforum.com and configured. As per my knowledge it leverages “yafmembership provider” for authentication and user management.

My Requirement==>
1. I would like to have a single system for authentication and user management. Currently above 2 sites have their own user management and data persistence mechanisim.
2. If user already logged-in into web.mysite.com then he would automatically logged- in into forum.mysite.com and vise versa for logged-out.
3. User registration, profile update , login will be done from common page for both the site.
4. I would like to maintain single database for user management for both the system









Sponsor
Offline ransems  
#2 Posted : 03 August 2014 15:55:57(UTC)
ransems


Rank: YAF Camper

Reputation:

Joined: 16/07/2014(UTC)
Posts: 11
Man
Canada
Location: Halifax

I would think this is a common and typical request, as I just started using YAF and already want this! Anyone?
Offline bbobb  
#3 Posted : 05 August 2014 14:46:04(UTC)
bbobb


Rank: YAF Developer

Reputation:

Medals: Medal of Honor Key: Given to pillars of the community who are key players in the YAF community and project.Medal of Honor for a YAF Database Key Player: Holds the key to YAF database. Bow down!Medal of Honor for the Support King: Given for answering tons of support questions and generally helping the community.Medal of Honor for the Support Knight: Given to a community member who has answered lots of support questions.

Joined: 21/10/2008(UTC)
Posts: 1,558
Man
Russian Federation
Location: Moscow

Thanks: 51 times
Was thanked: 287 time(s) in 253 post(s)
The most simple way would be to rewrite web.mysite.com code to use YAF providers.
Offline ransems  
#4 Posted : 05 August 2014 17:06:18(UTC)
ransems


Rank: YAF Camper

Reputation:

Joined: 16/07/2014(UTC)
Posts: 11
Man
Canada
Location: Halifax

Any code samples on how to do this? Any walkthroughs for that?
Offline ransems  
#5 Posted : 05 August 2014 17:08:25(UTC)
ransems


Rank: YAF Camper

Reputation:

Joined: 16/07/2014(UTC)
Posts: 11
Man
Canada
Location: Halifax

Someone must have done this?

Edited by user 05 August 2014 17:10:31(UTC)  | Reason: Reread first post

Offline tsb6670  
#6 Posted : 27 August 2014 23:51:32(UTC)
tsb6670


Rank: YAF Forumling

Reputation:

Joined: 13/08/2014(UTC)
Posts: 5

Was thanked: 1 time(s) in 1 post(s)
I'm still working on this - but to help move this topic along, I'll post what progress I have made so far.

(1) edit web.config and set the default loginUrl to your website login page (e.g. Login.aspx)
Code:
<authentication mode="Forms">
  <forms name=".YAFNET_Authentication" loginUrl="~/Login.aspx" protection="All" timeout="43200" cookieless="UseCookies"/>
</authentication>


(2) create a default login page (e.g. Login.aspx) and use the standard ASP.NET asp:Login control
Code:
<asp:Login ID="usrLogin" runat="server" BackColor="#F7F7DE" BorderColor="#CCCC99" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="10pt">
    <TitleTextStyle BackColor="#6B696B" Font-Bold="True" ForeColor="#FFFFFF" />
</asp:Login>


(3) in your Page_Load method for any page that requires authenticated users, redirect the request to your new Login.aspx page. This login page will log the user into the entire site including the YAF forum.
Code:
// check for authentication
if (!Request.IsAuthenticated)
{
    FormsAuthentication.RedirectToLoginPage();
    return;
}


At this stage, the changes above work to authenticate users. I'm still working on further integration using the YAF controls (pages/login.ascx) - which isn't working for me yet.

Tracy.

Offline tsb6670  
#7 Posted : 29 August 2014 23:18:12(UTC)
tsb6670


Rank: YAF Forumling

Reputation:

Joined: 13/08/2014(UTC)
Posts: 5

Was thanked: 1 time(s) in 1 post(s)
Following up from my previous post - to integrate YAF into an existing site and share the YAF authentication and membership providers, you will also need to create a new account page so new users don't have to navigate into the forum to create an account. To do this, create a new page such as NewAccount.aspx and drag and drop the ASP:CreateUserWizard control into your new page (standard ASP control).

Using the CreateUserWizard, add an OnCreatedUser event. This event is where you will store the created user default role. The default role for YAF members is "Registered" and the administration role is called "Administrators". If you don't assign a role to your new user accounts, YAF will respond with an error when you try to use that account.

Code:
protected void wizardCreateUser_CreatedUser(object sender, EventArgs e)
{
    String UserName = wizardCreateUser.UserName;
    if ((UserName != String.Empty) && (UserName.Length > 0))
    {
        Roles.AddUserToRole(wizardCreateUser.UserName, "Registered");
    }
    return;
}


Next, you'll want to create an OnContinueButtonClick event. Using this event, you'll redirect the user to an appropriate page such as the homepage.

Code:
protected void wizardCreateUser_ContinueButtonClick(object sender, EventArgs e)
{
	Response.Redirect("~/Default.aspx");
	return;
}


Note that the asp CreateUserWizard handles everything else using the providers you have defined in your web.conf file. For integration, you'll be using the YAF providers already discussed in my previous post.

Hope this helps.
Tracy.


Offline tsb6670  
#8 Posted : 29 August 2014 23:30:55(UTC)
tsb6670


Rank: YAF Forumling

Reputation:

Joined: 13/08/2014(UTC)
Posts: 5

Was thanked: 1 time(s) in 1 post(s)
Follow up on YAF membership roles - in your aspx code for non-forum pages, you can use the asp:LoginView control to filter content based on the YAF member role; for example, content for "Registered" members versus content for "Administrators" members.

Code:
<asp:LoginView ID="pageLoginView" runat="server">
	<RoleGroups>
		<asp:RoleGroup Roles="Registered">
			<ContentTemplate>
				<!-- Content for YAF Registered members (default role) -->
				<p>I AM A MEMBER</p>
			</ContentTemplate>
		</asp:RoleGroup>
		
		<asp:RoleGroup Roles="Administrators">
			<ContentTemplate>
				<!-- Content for YAF Administrators members (admin role) -->
				<p>I AM AN ADMINISTRATOR</p>
			</ContentTemplate>
		</asp:RoleGroup>
	</RoleGroups>
</asp:LoginView>

In the C# code behind, to find controls that you've placed in these RoleGroup containers, you'll need to using the asp:LoginView FindControl() method. Otherwise your code will not compile. The code below is an example of how to access a control using C#. The xml above doesn't have any controls in the RoleGroup containers.

Code:
TextBox myText= pageLoginView.FindControl("MyTextBoxID") as TextBox;


Cheers,
Tracy.
Offline sundramca  
#9 Posted : 09 October 2017 09:43:41(UTC)
sundramca


Rank: YAF Forumling

Reputation:

Joined: 09/10/2017(UTC)
Posts: 1

any one completed this recently can share their experience next steps
Offline paultg  
#10 Posted : 08 July 2018 15:12:32(UTC)
paultg


Rank: YAF Forumling

Reputation:

Joined: 08/07/2018(UTC)
Posts: 3
United Kingdom
Location: Wales

I'm also just getting to grips with YAF, as we've recently started using it as a staff forum. It'd be great if we could have our staff log in to our existing aspx portal page and have the system create a yaf login for them. In my case, the forum is a sub-folder application of the main portal.

If anyone's done this and has a simplified version that an amateur coder could use, I'm all ears, and potentially buying the beers.
Offline tha_watcha  
#11 Posted : 10 July 2018 18:13:37(UTC)
tha_watcha


Rank: YAF.NET Project Lead

Reputation:

Medals: Medal of Honor: Portal Puzzle Master: Portal Puzzle Master for DNNMedal of Honor Key: Given to pillars of the community who are key players in the YAF community and project.DNN Master: DNN Module ManBug Killer Medal of Honor: Medal for being a kick-ass bug killer!Medal of Honor for the Support King: Support King! Amazing asset to the YAF.NET Community.

Joined: 06/03/2010(UTC)
Posts: 3,923
Germany

Thanks: 73 times
Was thanked: 1190 time(s) in 1020 post(s)
It is possible. What authentication system are you using?
Offline paultg  
#12 Posted : 11 July 2018 19:44:18(UTC)
paultg


Rank: YAF Forumling

Reputation:

Joined: 08/07/2018(UTC)
Posts: 3
United Kingdom
Location: Wales

Originally Posted by: tha_watcha Go to Quoted Post
It is possible. What authentication system are you using?


Our login page to our roster page queries the db, if the user and pw match, it creates a session variable with the user name (same UN we use on the person's forum login).
Offline tha_watcha  
#13 Posted : 12 July 2018 08:51:05(UTC)
tha_watcha


Rank: YAF.NET Project Lead

Reputation:

Medals: Medal of Honor: Portal Puzzle Master: Portal Puzzle Master for DNNMedal of Honor Key: Given to pillars of the community who are key players in the YAF community and project.DNN Master: DNN Module ManBug Killer Medal of Honor: Medal for being a kick-ass bug killer!Medal of Honor for the Support King: Support King! Amazing asset to the YAF.NET Community.

Joined: 06/03/2010(UTC)
Posts: 3,923
Germany

Thanks: 73 times
Was thanked: 1190 time(s) in 1020 post(s)
Originally Posted by: paultg Go to Quoted Post
Originally Posted by: tha_watcha Go to Quoted Post
It is possible. What authentication system are you using?


Our login page to our roster page queries the db, if the user and pw match, it creates a session variable with the user name (same UN we use on the person's forum login).


And the DB is a custom db or did you mean the Forum database?

Rss Feed  Atom Feed
Users browsing this topic
guest (3)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Notification

Icon
Error