YAFLogo

Posted by: datafake - Friday, 21 November 2008 03:00:36
Hi all, Im new to YAF. I am about to write a fairly simple web site that will allow users to sign up, answer some survey questions and add some text ( their tip to other users ) We need to add a forum section to the site (YAF) that we will open once we have collected some users. I want users to sign up via my simple web app and be able to use the same credentials to login to YAF later. I have intalled the latest version of YAF 1.9.3 as it should allow me to use the ASP.NET membership provider to share users with my simple site. Everything seems to be working with the forum installed. To see how my membership adding code might work I tried adding a user using the ASP.NET configuration tool but got an error. Should I be able to do this or does YAF need extra fields. I also notice that although I have users in my forum the membership tables are still empty. Is this what I should expect. Can anyone show me some example code for adding a user to YAF from outside the forum. Thanks for any help or clarification Graeme YAF 1.9.3 .NET 3.5

Posted by: Mek - Friday, 21 November 2008 03:29:47
Have you changed the web.config Providers section to your asp.net default membership ones, it doesn't automatically guess which provider to use. Providers follow the same pattern as they based on the same underlying classes, so YAF does not require additional fields for Membership or Roles. Sounds like your problem lies elsewhere. Google: System.Web.Security.Membership.CreateUser for examples of how to create a user using Membership.

Posted by: datafake - Friday, 21 November 2008 04:00:52
Ill look into this. Make sure I actually have my membership set up correctly! Thanks for your help. Graeme

Posted by: datafake - Friday, 21 November 2008 07:35:11
Hi i am wrestling with my web.config If I go into the forum and register a new user then entries appear in both the yaf_User table and the asp_net_Users table. However If I create a new user using the ASP.NET configuration tool the user appears in the asp_net_Users table but not in the yaf_User table. Can anyone help me out? The connection string myConnectionString points to the SQL database that has the Membership tables, the YAF tables and tables I created. I am using 1.9.3, .NET 3.5 and working locally with VS2008 Express. Part of web.config: Also im using and have YAF in a folder called forum This is the only combination I can get to work but I dont understand what BaseUrl does as none of the tutorials suggest that it needs to be changed. Thanks Graeme

Posted by: CoreyRi1 - Friday, 21 November 2008 10:54:12
@datafake: Try to sign in to your forum using the user you just created. I know that sounds weird, but this is the way mine is setup and how it works: 1.User registers using a registration form which is outside of yaf. 2. User is added to the outside database but not the yaf database. 3. User signs in to YAF and if they have a matching account on the outside database, their user info is automatically copied to the yaf database and they are signed in. So it might be working afterall... The problem I'm having is that those users are not added to the _UserGroup table so they have no permissions by default...so you might need to find some work-around for that...I'm still trying to find the best method to fix the problem but I'm really not sure how to fix it at this point.

Posted by: datafake - Friday, 21 November 2008 13:54:18
Thanks for your help @CoreyRi1 ill give that a try! Graeme

Posted by: datafake - Monday, 24 November 2008 02:03:11
Hi, Whoo hoo Yes, I tried that and it works as you said. The permissions problem is because Role is not set in the code. When I use ASP.NET configuration tool I get to select a role, either "administrator" or "registered" and it works. I did this in code like this. [code] try { MembershipUser mu = Membership.CreateUser(username.Text, password.Text, email.Text); Roles.AddUserToRole(mu.UserName.ToString(), "registered"); // Display a status message validationmessage.Text += string.Format("User {0} was added to role {1}.", mu.UserName.ToString(),"registered"); } catch (MembershipCreateUserException ex) { validationmessage.Text += GetErrorMessage(ex.StatusCode); } string GetErrorMessage(MembershipCreateStatus status) { switch (status) { case MembershipCreateStatus.DuplicateUserName: return "Sorry that user name already exists. Please enter a different user name."; case MembershipCreateStatus.DuplicateEmail: return "A user name for that e-mail address already exists. Please enter a different e-mail address."; case MembershipCreateStatus.InvalidPassword: return "The password provided is invalid. Please enter a valid password value."; case MembershipCreateStatus.InvalidEmail: return "The e-mail address provided is invalid. Please check the value and try again."; case MembershipCreateStatus.InvalidAnswer: return "The password retrieval answer provided is invalid. Please check the value and try again."; case MembershipCreateStatus.InvalidQuestion: return "The password retrieval question provided is invalid. Please check the value and try again."; case MembershipCreateStatus.InvalidUserName: return "The user name provided is invalid. Please check the value and try again."; case MembershipCreateStatus.ProviderError: return "The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator."; case MembershipCreateStatus.UserRejected: return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator."; default: return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator."; } } [/code] Thanks again for your help Graeme

Posted by: CoreyRi1 - Wednesday, 26 November 2008 08:26:16
Great, glad to hear your forum is now working!:) Thanks for the tip about the permissions problem, but I'm not really sure what to do with that code. Do I need to insert that somewhere? Do I need to modify some code, if so, which file? Is that even YAF code, or is that from your other application? Heh, sorry...really haven't worked with asp much myself.

Posted by: datafake - Wednesday, 26 November 2008 08:38:07
Hi That code is outside the forum. Users to my site can sign up outside of the forum then use those details to log into the forum I have a page with a sign up form, when the user submits the form the code behind for the page captures the data they input and puts the extra details I need into my DB tables. After that the code uses the built in membership classes to add a new user to the asp_net membership system. These two lines add new users that my app and YAF will share MembershipUser mu = Membership.CreateUser(username.Text, password.Text, email.Text); Roles.AddUserToRole(mu.UserName.ToString(), "registered"); The second line adds users to the registered role. Without it i would get the problem of the new user having no permissions. Equivalent to not checking a role checkbox when using the asp.net configuration tool. Your permissions problem may be because you are not selecting a role when ading users with the asp.net configuration tool. Also if your web.config is wrong the asp.net configuration tool will not show any roles to select Graeme

Posted by: evil wiggins - Wednesday, 4 February 2009 09:04:09
Hi I am also having problem with this This is the web.config section, if anybody can show me what I am doing wrong please? [code] [/code]

Posted by: Mek - Wednesday, 4 February 2009 11:26:46
[quote=evil wiggins]Hi I am also having problem with this [/quote] Your web.config seems to be a mash; why are you using Standard Role Providers with our Membership and Profile??? Makes no sense. Look at the web.configs bundled with 1.93 RC2 in the web.configs folder to see how these should be set up. And if I'm entirely honest I'd say use our web.config then alter them to suit whatever your trying to do, rather than start with another web.config and try to get YAF to work with it. Much easier imo.

Posted by: evil wiggins - Thursday, 5 February 2009 01:54:54
the problem is I already have 300+ users in the membership table, if i try to uise the yaf stuff i can't log in. Has anybody successfully integrated into an existing membership table I followed all the instructions but it just would not work. with the above "mash" (nice word) I can login and i am logged in to the forum, but i think that is only because i am the admin user, i can't see any other members listed for the forum

Posted by: Mek - Thursday, 5 February 2009 04:25:20
Which membership table? Cos your "mash" is pointing the membership at our membership provider, yet your roles is pointing at the standard asp.net roles. When you want both to be probably point at the standard providers (probably the profiles as well, but I believe you have to inherit the profile provider. There has been a discussion about it on the forums).

Posted by: evil wiggins - Thursday, 5 February 2009 06:22:02
Ok, managed to get it working. Though now the images are broken links and the theme is not displaying, yet it works fine on localhost, but as soon as i put it on my site, nothing.

Posted by: benwhyte83 - Thursday, 5 February 2009 20:42:30
Hey, I am getting this error [code]Could not load type 'YAF.Providers.Profile.ProfileProvider'[/code] This is what I have set up for the providers in the web.config file [code] [/code] I am pretty sure I have copied across all the correct bin files, app_code and other web.config keys. Is there anything I could have missed?

Posted by: benwhyte83 - Thursday, 5 February 2009 21:32:48
sorry i fixed it, type was meant to end in .YafProfileProvider [quote=benwhyte83]Hey, I am getting this error [code]Could not load type 'YAF.Providers.Profile.ProfileProvider'[/code] This is what I have set up for the providers in the web.config file [code] [/code] I am pretty sure I have copied across all the correct bin files, app_code and other web.config keys. Is there anything I could have missed?[/quote]

Posted by: evil wiggins - Friday, 6 February 2009 01:57:54
OK my bad on the missing images :oops: I have a working version now, i think the main problem was that i was expecting to see a full list of members when i clicked the members link. But this only populates as each member logs in. So now i have 5 showing as 5 have logged in. I have a copy of the web.config area that now works. Hope this is of some help to any others. [code] [/code]

Posted by: Mek - Friday, 6 February 2009 02:19:02
[quote=evil wiggins] But this only populates as each member logs in. So now i have 5 showing as 5 have logged in. [/quote] Yup we have to sync with the Membership. Though I think it does a bigger mass sync on the install, perhaps due your original issues this didn't get run.

Posted by: mothswiller - Friday, 24 April 2009 07:47:06
There are security issues with using a Custom Provider in a shared environment see this [url=http://forum.yetanotherforum.net/yaf_postst6686_1and1-and-yaf-193-beta--webconfig.aspx]thread[/url]