YAFLogo

guest
  • guest
  • Guest Topic Starter
18 years ago
hi all

i have been trying to integrate YAF into my ASP.net application and also posted message here but no luck. and decided to work it out myself.

now i am able to login from my ASP.net application and automatically i am also logged into YAF, there is no need to go to login page of YAF. :-)

hopefully i will give out details today or tommorow.

now i am done with this i have started to work on another thing which is pretty easy but i am not sure what to do.

i need to change links on Header toolbar to go to my pages, but dont know what to do. i tried to chaged few things in forumpage.cs and forum.cs. but it didn't work out like i want.

plz help any body know how to do it.

OR if i can add my link in header bar.

thanx

Sponsor
guest
  • guest
  • Guest Topic Starter
18 years ago
I'm interesting in YAF integration solution. I just installed the forum and I need to integrate it into a Sharepoint website ... I'm new so any help is appreciated ... Thanks to all.

Bye.

:)

guest
  • guest
  • Guest Topic Starter
18 years ago
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 tag in your application's web.config and same 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

flyer299
18 years ago
When you add to the YAF User table, what do you put in for the Password Column?

Any other tables you need to insert into?


guest
  • guest
  • Guest Topic Starter
18 years ago
see first two lines in the code i have given

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

its taking password from your form and Hash it, so that it can be stored and used as YAF wants it to. you dont need any other table.

Hope it works.

regards

guest
  • guest
  • Guest Topic Starter
18 years ago
Hi all, im also trying to integrate the forum on my existing website, my question is can i use plain password text to store on YAF database? :?:

thanks in advance.

More power to YAF :d

guest
  • guest
  • Guest Topic Starter
18 years ago
hi

technically you can, but it will require's changing in the code. its better to leave it hashed for security purpose.

regards

flyer299
18 years ago
Correct me if I am wrong... The code above does not include adding new users to the YAF database. You are doing something else to keep your user SAM in synch with YAF's SAM, right?
flyer299
18 years ago
I got the entire thing working on Friday. Must say I am very impressed with the results. I am using Active Directory as our main SAM. I have a page that redirects the user to YAF. That page tries a login as you suggested:

Dim sPassword As String = FormsAuthentication.HashPasswordForStoringInConfigFile(Password.Text, "md5")

Dim userID As Object = yaf.DB.user_login(1, UserName.Text, sPassword)

If it fails, I either create a new user account or update the password (using stored procedures I wrote) then redirects them to the forums. This handles both new users and if the password changes in AD.

Thanks for the heads up on this code, it really got me thinking on how to do this.


guest
  • guest
  • Guest Topic Starter
18 years ago
Hi Ken,

Would you mind sharing your SP's with us?

Thanks,

Blackwater

guest
  • guest
  • Guest Topic Starter
18 years ago
yeah i doesn't include code to add users in the database.
guest
  • guest
  • Guest Topic Starter
17 years ago
Hi all... Im so close i can taste it but i am struggling to get the authentication to work just right with 1.9 of YAF.

i followed what Zeee had suggeseted + added code to keep the databaseses and passwords in sync. I did that by adding a stored prcedure to populate the yaf_user and the yaf_usergroups tables. In Yaf I always set the password to be the same for all users rather than try to keep it in sync with my main app since i only want to authenticate againmst that application. I figured I don't need user specific passwords in YAF.

Right back to my issue...

Things appear to authenticate in both my main application and YAF which is in a sub application folder. all looks well in YAF but in my main app the user that is now logged in will include the YAF user ID and board ID as part of the user. So if I log in as the 'admin' user for example my main app sees the user as '2;1;admin' how can i get around this I wonder??? Ive tried to figure it out but am at a loss.

any ideas anyone.. beg beg...

flyer299
17 years ago
When I did my integration the Auth Ticket that YAF used was different than the one that I used. Basically I was stashing a Username in the ticket, and YAF was putting the "1;2;Admin" in the ticket.

So I modified my application to read both "{username}" and "{1;2;admin;{username}" in the auth ticket and it worked great. Lucky for my I handled all of my Authentication in one place in my application, so it was an easy modification.


bigtoga
17 years ago
http://www.LearnSqlServer.com/  and my forums are in a subdomain, a completely separate app. I think that, b/c you are hard coding the machine key, that it would work but I thought I would ask 🙂
Check out my implementation of YAF: http://forums.learnsqlserver.com/ .

I am also a SQL Server and .NET trainer over at http://www.learnitfirst.com 

guest
  • guest
  • Guest Topic Starter
17 years ago

Hi all

i. Add a tag in your application's web.config and same in Yaf's web.config i.e. Replace $$ with your validationKey and decryptionKey

<system.web>
<machineKey validationKey="$$" decryptionKey="$$" validation="SHA1" />
	</system.web>

[code]

Zeeshan

zeee wrote:

if i edit the machineKey tag, will this affect the entire web server? will this affect the machine.config file? in other words, if i am hosting my site on a shared server, will making this change affect the other sites.

also, where can i find a validationKey and the decryptionKey so i can make the change to the machineKey tag.