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


Rank: YAF Forumling

Reputation:

Joined: 5/26/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 : Sunday, August 3, 2014 7:55:57 AM(UTC)
ransems


Rank: YAF Camper

Reputation:

Joined: 7/16/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 : Tuesday, August 5, 2014 6:46:04 AM(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: 10/21/2008(UTC)
Posts: 1,558
Man
Russian Federation
Location: Moscow

Thanks: 51 times
Was thanked: 288 time(s) in 254 post(s)
The most simple way would be to rewrite web.mysite.com code to use YAF providers.
Offline ransems  
#4 Posted : Tuesday, August 5, 2014 9:06:18 AM(UTC)
ransems


Rank: YAF Camper

Reputation:

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

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


Rank: YAF Camper

Reputation:

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

Someone must have done this?

Edited by user Tuesday, August 5, 2014 9:10:31 AM(UTC)  | Reason: Reread first post

Offline tsb6670  
#6 Posted : Wednesday, August 27, 2014 3:51:32 PM(UTC)
tsb6670


Rank: YAF Forumling

Reputation:

Joined: 8/13/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 : Friday, August 29, 2014 3:18:12 PM(UTC)
tsb6670


Rank: YAF Forumling

Reputation:

Joined: 8/13/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 : Friday, August 29, 2014 3:30:55 PM(UTC)
tsb6670


Rank: YAF Forumling

Reputation:

Joined: 8/13/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 : Monday, October 9, 2017 1:43:41 AM(UTC)
sundramca


Rank: YAF Forumling

Reputation:

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

any one completed this recently can share their experience next steps
Rss Feed  Atom Feed
Users browsing this topic
guest
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