本文介绍了将YAF与我现有的网站整合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

嘿,我是 YAF的新手 [ ^ ] !!!

在我的网站上,我有自己的登录名&注册模块.而且我不使用ASP.net成员身份.
我想将YAF整合到我的网站中.
据我所知,YAF需要ASP.net成员身份,但在Google上搜索了很多,但无法弄清楚如何实现我的登录& ;; YAF的注册地区?

在此先感谢!!!

Hey I''m new to YAF[^]!!!

In my website I have my own login & registration modules.And i''m not using ASP.net membership.
I want to integrate YAF into my website.
As far as I know YAF requires ASP.net membership,googled alot ,but unable to figure out how to achieve my login & registraion for YAF???

Thanks in advance!!!

推荐答案

private void CreateUser(String sApplicationName, String sUserName, String sPassword, String sEmail)
        {
            YafMembershipProvider mb = (YafMembershipProvider)System.Web.Security.Membership.Providers["YafMembershipProvider"];
            int? forumUserID = 0;

            if (!mb.ValidateUser(sUserName, sPassword))
            {
                MembershipCreateStatus status;
                MembershipUser forumUser = mb.CreateUser(sUserName, sUserName, sUserName, "question", "answer", true, null, out status);

                // create the user in the YAF DB as well as sync roles...
                forumUserID = RoleMembershipHelper.CreateForumUser(forumUser, 1);

                RoleMembershipHelper.SetupUserRoles(1, sUserName);
                RoleMembershipHelper.AddUserToRole(sUserName, "Registered");

                // create empty profile just so they have one
                YafUserProfile userProfile = YafUserProfile.GetProfile(sUserName);
                userProfile.Homepage = "fwd.com";

                // setup their inital profile information
                userProfile.Save();
            }
            else
            {
                DataTable results =(DataTable) YAF.Classes.Data.DB.UserFind(1, false, sUserName, sUserName, sUserName, null, null);
                //DataTable results = YAF.Classes.Data.DB.UserFind(1, false, sUserName, sUserName);
                if (results.Rows.Count > 0)
                {
                    forumUserID = (int)results.Rows[0]["UserID"];
                }
            }

            FormsAuthentication.SetAuthCookie(sUserName, false);
        }


现在我可以从我的注册页面注册到YAF.


Now I''m able to register from my sign up page into YAF.



这篇关于将YAF与我现有的网站整合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 12:21