guest
2007-01-11T02:56:17Z
Hi all
As promised i am giving solution to web site integration today.8)

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
<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

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:
cheers
Zeeshan
Sponsor
Jaben
  •  Jaben
  • 100% (Exalted)
  • YAF Developer
2007-01-11T17:54:12Z
Nice work Zeee! Thanks for offering a solution for the community.
guest
2007-01-11T21:26:34Z
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
Jaben
  •  Jaben
  • 100% (Exalted)
  • YAF Developer
2007-01-12T00:14:19Z
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.
guest
2007-05-29T01:27:55Z
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
guest
2007-06-18T19:34:49Z
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")
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
2008-10-22T10:13:38Z

About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved