Welcome Guest Search | Active Topics | Log In | Register

YAF and Your Website INTEGRATION Solution Options · View
zeee
#1 Posted : Thursday, January 11, 2007 1:56:17 PM

Rank: YAF Camper



Joined: 1/6/2007
Posts: 24
Location: Pakistan
Hi all
As promised i am giving solution to web site integration today.Cool

To integrate your current ASP.net application with YAF, so that you login only once in your ASP.net application and it automatically logins you to YAF also. Its simple as 123 but the only bad thing is you have two users table and you have to make updates to both tables. If anyone else has done the same thing in some other easy way do let me konw
Just follow the steps
i. Add a <machineKey> tag in your application's web.config and same <machineKey> in Yaf's web.config i.e. Replace $$ with your validationKey and decryptionKey
Code:
<system.web>
<machineKey validationKey="$$" decryptionKey="$$" validation="SHA1" />
    </system.web>

ii. Use your applications login page and onclick event of your login button add following code. dont forget to rename your textboxes to corelate with the code or vice versa
Code:

Dim sPassword As String = FormsAuthentication.HashPasswordForStoringInConfigFile(Password.Text, "md5")
        Dim userID As Object = yaf.DB.user_login(1, UserName.Text, sPassword)

        If Not userID Is DBNull.Value Then
            Dim idName As String = String.Format("{0};{1};{2}", userID, 1, UserName.Text)

            If (Request.QueryString("ReturnUrl") <> Nothing) Then
                FormsAuthentication.RedirectFromLoginPage(idName, True)
            Else
                FormsAuthentication.SetAuthCookie(idName, True)
                'yaf.Forum.
                Response.Write("authen")
            End If
        Else
            'AddLoadMessage(GetText("password_error"))
        End If


Thats all you need. use your login page to login and then go to default.aspx or any page on YAF Forum. you will be already logged in and authentication ticked/sessoin is shared.Evil or Very Mad
cheers
Zeeshan
Zeeshan Nasir
never stop learning
http://zeeshan.terapad.com/
Jaben
#2 Posted : Friday, January 12, 2007 4:54:12 AM

Rank: YAF Head Dude



Joined: 10/10/2004
Posts: 3,050
Location: Honolulu, HI
Nice work Zeee! Thanks for offering a solution for the community.
"When you are grateful, fear disappears and abundance appears”."

zeee
#3 Posted : Friday, January 12, 2007 8:26:34 AM

Rank: YAF Camper



Joined: 1/6/2007
Posts: 24
Location: Pakistan
thnx Jaben.
i was wonderin is their any way we can make the Expand/Collapse with javascript, so that page dont submit everytime we expand/collapse a section.
regards
Zeeshan Nasir
never stop learning
http://zeeshan.terapad.com/
Jaben
#4 Posted : Friday, January 12, 2007 11:14:19 AM

Rank: YAF Head Dude



Joined: 10/10/2004
Posts: 3,050
Location: Honolulu, HI
zeee wrote:
thnx Jaben.
i was wonderin is their any way we can make the Expand/Collapse with javascript, so that page dont submit everytime we expand/collapse a section.
regards

The quickreply already has that code. You're welcome to adapt that to the other sections of the site.
"When you are grateful, fear disappears and abundance appears”."

jjme88
#5 Posted : Tuesday, May 29, 2007 12:27:55 PM

Rank: YAF Forumling


Joined: 5/16/2007
Posts: 7
Location: UK
Hi this works a treat.. but I now have an issue in my main application...

my main app uses the standard ASP.NET login controls... so now when users log in to main migh site it says someithing like;

Welcome Back 19;1;UserName it now includes the users id and borad id in the name.. is there a way to strip them out??
ive tried to find how YAF handles the display of the user name but I guess its all in the .dll file that i cant get at??

if anyone has any thoughts I would be very grateful.

thx
jj
muncher
#6 Posted : Tuesday, June 19, 2007 6:34:49 AM
Rank: Member


Joined: 6/16/2007
Posts: 10
Location: nyc
I am running yaf 1.9.1 rc1 in a subfolder that is setup as an application. When I try this method of integration, it seems yaf is trying to use the web.config in my root and not the web.config in /forum/ as I get the following error message. Any help would be greatly appreciated =)

Failed to get configuration from Web.config.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ApplicationException: Failed to get configuration from Web.config.

Source Error:

Line 32:
Line 33: Dim sPassword As String = FormsAuthentication.HashPasswordForStoringInConfigFile(Password.Text, "md5"Wink
Line 34: Dim userID As Object = yaf.DB.user_login(1, UserName.Text, sPassword)
Line 35:
Line 36: If Not userID Is DBNull.Value Then


Source File: E:\web\compareprep\htdocs\login.aspx.vb Line: 34

Stack Trace:

[ApplicationException: Failed to get configuration from Web.config.]
yaf.Config.get_configSection() +144
yaf.DB.ExecuteScalar(SqlCommand cmd) +67
yaf.DB.user_login(Object boardID, Object name, Object password) +150
Default2.Login1_Authenticate(Object sender, AuthenticateEventArgs e) in E:\web\compareprep\htdocs\login.aspx.vb:34
System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +106
System.Web.UI.WebControls.Login.AttemptLogin() +105
System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +99
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +115
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +163
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
Schmakt
#7 Posted : Wednesday, October 22, 2008 9:13:38 PM

Rank: YAF Forumling


Joined: 10/14/2008
Posts: 2
Location: charlotte, nc
thank you!
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.

YAFPro Theme Created by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.3 RC2 | YAF © 2003-2008, Yet Another Forum.NET
This page was generated in 0.107 seconds.

SourceForge.net Logo Powered by ASP.NET v2.0 411ASP.NET