I normally code in C#
I have a website that has it's own user database, not using the ASP.NET Membership provider. In fact, this website doesn't have any log in at all, but user details are stored when people register for the organization.
So, I have a database with email addresses and names and I want to add these users to the YAF user database and assign a password for them.
My thought is that my program would run every day and automatically add any users who have registered on the original site and send them an email with their password.
I have added the connectionStrings and system.web sections to my app.config exactly as they are in the YAF configs.
I have also added the YAF.dll to my references.
I can run YAF.Providers.Membership.DB.Current.CreateUser("YetAnotherForum", "TestUser", FormsAuthentication.HashPasswordForStoringInConfigFile("TestPassword!", "SHA1"), "", 0, "email@example.com", "", "", true, YAF.Providers.Profile.DB.Current.GetProviderUserKey("YetAnotherForum", "TestUser"));
I get no errrors, but the user does not appear in the YAF database or Admin panel.
If you could offer any help on what I am missing or doing wrong I would appreciate it.
Thanks in advance!
var pass = Membership.GeneratePassword(32, 16);
var securityAnswer = Membership.GeneratePassword(64, 30);
var securityQuestion = "Answer is a generated Pass";
var user = YafContext.Current.Get<MembershipProvider>().CreateUser(
this.Get<MembershipProvider>().RequiresQuestionAndAnswer ? securityQuestion : null,
this.Get<MembershipProvider>().RequiresQuestionAndAnswer ? securityAnswer : null,
// setup inital roles (if any) for this user
// create the user in the YAF DB as well as sync roles...
int? userID = RoleMembershipHelper.CreateForumUser(user, YafContext.Current.PageBoardID);
// create empty profile just so they have one
YafUserProfile userProfile = YafUserProfile.GetProfile( "username");
// send user register notification to the new users
user, pass, securityAnswer, "NOTIFICATION_ON_REGISTER");
var autoWatchTopicsEnabled = this.Get<YafBoardSettings>().DefaultNotificationSetting
// save the settings...