jshepler
2009-05-07T08:12:38Z
The mebership provider (yaf's or asp.net's or whatever) is basically a DAL behind asp.net's membership interface. Code (yaf and your site) use asp.net membership's public methods to perform authentication and membership management. Yaf uses those methods, so asp.net membership must be setup for yaf to work.

You could write your own membership provider (that uses your existing database) and drop that in. Then asp.net membership will authenticate against your existing database and yaf will automatically sync itself with your existing users (via asp.net membership via your custom provider). You can read up on writing a custom membership provider here . For a real-world working example of a custom membership provider, download the yaf source and look at theirs.

I understand your site has its own custom authentication, but it should be fairly easy to abstract that out into a custom provider.

Again, if you don't want to go that route but still want to use yaf, you'll probably have to use an older version. I seem to remember seeing old threads of people detailing out the code they wrote to do it, but I can't find them. Sorry.

not jsheLPer
dchadha
2009-05-07T08:31:54Z
Hi J.Shepler,

I think I am starting to go into right direction after getting useful information from you and other users in this forum. I will try to wrap my custom authentication using asp.net membership provider.

Sorry about misspelling your name.

Again thanks for the prompt reply.

Regards
dchadha

jshepler wrote:

The mebership provider (yaf's or asp.net's or whatever) is basically a DAL behind asp.net's membership interface. Code (yaf and your site) use asp.net membership's public methods to perform authentication and membership management. Yaf uses those methods, so asp.net membership must be setup for yaf to work.

You could write your own membership provider (that uses your existing database) and drop that in. Then asp.net membership will authenticate against your existing database and yaf will automatically sync itself with your existing users (via asp.net membership via your custom provider). You can read up on writing a custom membership provider here . For a real-world working example of a custom membership provider, download the yaf source and look at theirs.

I understand your site has its own custom authentication, but it should be fairly easy to abstract that out into a custom provider.

Again, if you don't want to go that route but still want to use yaf, you'll probably have to use an older version. I seem to remember seeing old threads of people detailing out the code they wrote to do it, but I can't find them. Sorry.


cartaysm
  •  cartaysm
  • 58.4% (Neutral)
  • YAF Forumling Topic Starter
2009-05-11T16:40:17Z
For what its worth:
I got around integration with one minor error, the page has to be refreshed before the user is recognized that's it. So I will break it down real quick.
http://forums.mysite.com 
http://forums.mysite.com . The reason I needed this was because mysite.com viewed forums.mysite.com via an iframe.
http://mysite.com  does not use memberships
http://forums.mysite.com  does use memberships
So there is a run down of what I was working with. Here is my fix:

First write a stored procedure to add all the fields into the YAF database:
yaf_prov_Membership
yaf_prov_RoleMembership
What this will do is when registered for mysite.com it automatically adds the users into the YAF database.

Second add the dll's from the forum to your bin (just the YAF) and next (this will take some digging so don't try it if you dont know what you are doing), but you need to pull out the salt generator and put it in your code via YAF SOURCE\YAF.Providers\Membership\YafMembershipProvider.cs
with that you can now generate the same salts as yaf.

Next call the salt and add it to this string below.
Dim Hashedpass As String = YAF.Providers.Membership.YafMembershipProvider.Hash(clearText, "SHA1", Salt, True, False, "", "", False)

What this does is generate the exact hashed password that YAF does. So if you store the salt and the hashed password you have successfully stored exactly as YAF.

So on your login page you would simply not generate the salt. You would pull the salt from your database and place it in the string above.
http://mysite.com  database to hold salts. What this does is saves the password and salt exactly like YAF, easy to recall.)

Finally: and this is where my error comes in, I just have this code in the wrong spot. But you add a forums auth ticket YAF forums will know who you are. I added it on the default page so my forums site requires a refresh before working but this can easily be fixed.

So just put the username in and role id from the yaf database and thats it. Works like a charm

FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, Username, DateTime.Now, DateTime.Now.AddMinutes(60), false, RoleID);
String encTicket = FormsAuthentication.Encrypt(authTicket);
HttpCookie faCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
Response.Cookies.Add(faCookie);
jshepler
2009-05-12T03:46:26Z
cartaysm wrote:

For what its worth:
I got around integration with one minor error, the page has to be refreshed before the user is recognized that's it.

<snip>

FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, Username, DateTime.Now, DateTime.Now.AddMinutes(60), false, RoleID);
String encTicket = FormsAuthentication.Encrypt(authTicket);
HttpCookie faCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
Response.Cookies.Add(faCookie);



FormsAuthentication.SetAuthCookie(username, remember);
Response.Redirect(Request.RawUrl);

not jsheLPer
Similar Topics
Users browsing this topic

    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