Boskone
  •  Boskone
  • 100% (Exalted)
  • YAF MVP Topic Starter
2008-06-10T12:28:17Z
I finally had some time to test this out.
There are only a couple of things that caused me problems.

It was a bit of a challenge merging the web.config files into one.

During the install of the DB, I could select my existing DNN administrator, but I still had to add that user to the yaf_prov_membership table.

In Install/default.aspx.cs:

				// try to get data for the existing user...
				user = Membership.GetUser( ExistingUserName.Text.Trim() );
                

				if ( user == null )
				{
					AddLoadMessage( "Existing user name is invalid and does not represent a current user in the membership store." );
					return false;
				}
                // Add for DNN
                if (YAF.Classes.Config.IsDotNetNuke)
                {
                    YAF.Providers.Membership.DB.CreateUser("DotNetNuke", user.UserName, "", "", 2, user.Email, "", "", true, user.ProviderUserKey);
                }
                //END
  

The only other item I noticed which is minor, there is no need to display "Register | Login/Logout" in the top header.

In YAF.Controls/Header.cs

                /* TODO: help is currently useless...
                if ( IsAdmin )
                    header.AppendFormat( String.Format( "	<a target='_top' href=\"{0}\">{1}</a> | ", YafBuildLink.GetLink( ForumPages.help_index ), GetText( "TOOLBAR", "HELP" ) ) );
                */

                if (General.CheckPermission(PageContext, PageContext.BoardSettings.SearchPermissions)) buildHeader.AppendFormat(String.Format("	<a href=\"{0}\">{1}</a> | ", YafBuildLink.GetLink(ForumPages.search), PageContext.Localization.GetText("TOOLBAR", "SEARCH")));
                if (PageContext.IsAdmin)
                    buildHeader.AppendFormat(String.Format("	<a target='_top' href=\"{0}\">{1}</a> | ", YafBuildLink.GetLink(ForumPages.admin_admin), PageContext.Localization.GetText("TOOLBAR", "ADMIN")));
                if (PageContext.IsModerator || PageContext.IsForumModerator)
                    buildHeader.AppendFormat(String.Format("	<a href=\"{0}\">{1}</a> | ", YafBuildLink.GetLink(ForumPages.moderate_index), PageContext.Localization.GetText("TOOLBAR", "MODERATE")));
                buildHeader.AppendFormat(String.Format("	<a href=\"{0}\">{1}</a> | ", YafBuildLink.GetLink(ForumPages.active), PageContext.Localization.GetText("TOOLBAR", "ACTIVETOPICS")));
                if (!PageContext.IsGuest)
                    buildHeader.AppendFormat(String.Format("	<a href=\"{0}\">{1}</a> | ", YafBuildLink.GetLink(ForumPages.cp_profile), PageContext.Localization.GetText("TOOLBAR", "MYPROFILE")));
                if (General.CheckPermission(PageContext, PageContext.BoardSettings.MembersListViewPermissions)) buildHeader.AppendFormat(String.Format("	<a href=\"{0}\">{1}</a> ", YafBuildLink.GetLink(ForumPages.members), PageContext.Localization.GetText("TOOLBAR", "MEMBERS")));
                if (!Classes.Config.IsDotNetNuke)
                {
                    buildHeader.AppendFormat(String.Format(" | <a href=\"{0}\" onclick=\"return confirm('{2}');\">{1}</a>", YafBuildLink.GetLink(ForumPages.logout), PageContext.Localization.GetText("TOOLBAR", "LOGOUT"), PageContext.Localization.GetText("TOOLBAR", "LOGOUT_QUESTION")));
                }
            }
            else
            {
                buildHeader.AppendFormat(String.Format(@"<td style=""padding:5px"" class=""post"" align=""left""><b>{0}</b></td>", PageContext.Localization.GetText("TOOLBAR", "WELCOME_GUEST")));

                buildHeader.AppendFormat(@"<td style=""padding:5px"" align=""right"" valign=""middle"" class=""post"">");
                if (General.CheckPermission(PageContext, PageContext.BoardSettings.SearchPermissions)) buildHeader.AppendFormat(String.Format("	<a href=\"{0}\">{1}</a> | ", YafBuildLink.GetLink(ForumPages.search), PageContext.Localization.GetText("TOOLBAR", "SEARCH")));
                buildHeader.AppendFormat(String.Format("	<a href=\"{0}\">{1}</a> | ", YafBuildLink.GetLink(ForumPages.active), PageContext.Localization.GetText("TOOLBAR", "ACTIVETOPICS")));
                if (General.CheckPermission(PageContext, PageContext.BoardSettings.MembersListViewPermissions)) buildHeader.AppendFormat(String.Format("	<a href=\"{0}\">{1}</a> ", YafBuildLink.GetLink(ForumPages.members), PageContext.Localization.GetText("TOOLBAR", "MEMBERS")));

                string returnUrl = GetReturnUrl();
                if (!Classes.Config.IsDotNetNuke)
                {
                    buildHeader.AppendFormat(String.Format(" | <a href=\"{0}\">{1}</a>", (returnUrl == string.Empty) ? YafBuildLink.GetLink(ForumPages.login) : YafBuildLink.GetLink(ForumPages.login, "ReturnUrl={0}", returnUrl), PageContext.Localization.GetText("TOOLBAR", "LOGIN")));

                    if (!PageContext.BoardSettings.DisableRegistrations)
                    {
                        buildHeader.AppendFormat(String.Format(" | <a href=\"{0}\">{1}</a>", (PageContext.BoardSettings.ShowRulesForRegistration ? YafBuildLink.GetLink(ForumPages.rules) : YafBuildLink.GetLink(ForumPages.register)), PageContext.Localization.GetText("TOOLBAR", "REGISTER")));
                    }
                }
            }

I used the same DotNetNukeModule and DotNetNukeModuleEdit files that were in my last post about Dnn integration.

Testing on a single portal, I created 3 different forums and everything worked as expected.

I must say well done on the Beta release!
Boskone - A DotNetNuke user.
RDSCC 
Sponsor
Jaben
  •  Jaben
  • 100% (Exalted)
  • YAF Developer
2008-06-10T13:55:49Z
Thanks for the DNN testing. You are using the YAF membership providers? Why not use the DNN membership providers?
Boskone
  •  Boskone
  • 100% (Exalted)
  • YAF MVP Topic Starter
2008-06-10T15:11:46Z
Dnn only uses the AspNetMembership provider. It has its own custom role and profile providers.
When I don't make any changes to the install.cs, I get sql insert errors such as UserID cannot be null.
I don't know why this happens.

I may be doing something wrong in the web.config. Here are the relevant sections:

    <membership defaultProvider="AspNetSqlMembershipProvider" userIsOnlineTimeWindow="15">
      <providers>
        <clear />
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="SiteSqlServer" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="0" requiresUniqueEmail="false" passwordFormat="Encrypted" applicationName="DotNetNuke" description="Stores and retrieves membership data from the local Microsoft SQL Server database" />
      </providers>
    </membership>
    <!-- YAF Support -->
    <roleManager enabled="true" defaultProvider="YAFRoleProvider">
      <providers>
        <clear/>
        <add connectionStringName="SiteSqlServer" applicationName="DotNetNuke" name="YafRoleProvider" type="YAF.Providers.Roles.YafRoleProvider"/>
      </providers>
    </roleManager>
    <profile enabled="true" defaultProvider="YAFProfileProvider" inherits="YAF.Classes.Utils.YafUserProfile">
      <providers>
        <clear/>
        <add connectionStringName="SiteSqlServer" applicationName="DotNetNuke" name="YafProfileProvider" type="YAF.Providers.Profile.YafProfileProvider"/>
      </providers>
    </profile>

  <dotnetnuke>
...
...
    <members defaultProvider="AspNetMembershipProvider">
      <providers>
        <clear />
        <add name="AspNetMembershipProvider" type="DotNetNuke.Security.Membership.AspNetMembershipProvider, DotNetNuke.Provider.AspNetProvider" providerPath="~\Providers\MembershipProviders\AspNetMembershipProvider\" />
      </providers>
    </members>
    <roles defaultProvider="DNNRoleProvider">
      <providers>
        <clear />
        <add name="DNNRoleProvider" type="DotNetNuke.Security.Membership.DNNRoleProvider, DotNetNuke.Provider.DNNProvider" providerPath="~\Providers\MembershipProviders\DNNMembershipProvider\" />
      </providers>
    </roles>
    <profiles defaultProvider="DNNProfileProvider">
      <providers>
        <clear />
        <add name="DNNProfileProvider" type="DotNetNuke.Security.Profile.DNNProfileProvider, DotNetNuke.Provider.DNNProvider" providerPath="~\Providers\MembershipProviders\DNNMembershipProvider\" />
      </providers>
    </profiles>
  </dotnetnuke>

The role and profile providers are within the <dotnetnuke> tags. Will YAF see this section?
Boskone - A DotNetNuke user.
RDSCC 
Boskone
  •  Boskone
  • 100% (Exalted)
  • YAF MVP Topic Starter
2008-06-13T14:34:04Z
I did some more testing with the Dnn membership and could not find any other way to get YAF to use DNN members.

I made an attempt to sync Dnn roles with YAF and did have some success.

In DotNetNukeModule.cs:

            // Check for user
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                DotNetNuke.Entities.Users.UserInfo DnnUserInfo;
                DotNetNuke.Entities.Portals.PortalSettings _portalSettings = (DotNetNuke.Entities.Portals.PortalSettings)HttpContext.Current.Items["PortalSettings"];
                DnnUserInfo = DotNetNuke.Entities.Users.UserController.GetUser(_portalSettings.PortalId, this.UserId, false);

                //Need the user provider user key
                MembershipUser DnnUser = Membership.GetUser(DnnUserInfo.Username, true);
                
                //Make sure this user is in the YAF DB
                DataRow yafuser = YAF.Providers.Membership.DB.GetUser("DotNetNuke", DnnUser.ProviderUserKey, DnnUserInfo.Username, true);
                    if (yafuser == null)
                    {
                        //Create the user in YAF
                        YAF.Providers.Membership.DB.CreateUser("DotNetNuke", DnnUserInfo.Username, "password", "", 2, DnnUserInfo.Membership.Email, "", "", true, DnnUser.ProviderUserKey);
                        //get the roles for this user and copy them to the YAF roles
                        DotNetNuke.Security.Roles.RoleController _DnnRoleController = new DotNetNuke.Security.Roles.RoleController();
                        ArrayList DnnRoleList;
                        DnnRoleList = _DnnRoleController.GetUserRoles(_portalSettings.PortalId, DnnUserInfo.UserID);
                        foreach (DotNetNuke.Entities.Users.UserRoleInfo rolename in DnnRoleList)
                        {
                            if (!Roles.RoleExists(rolename.RoleName))
                            {
                                Roles.CreateRole(rolename.RoleName);
                                Roles.AddUserToRole(DnnUser.UserName, rolename.RoleName);
                            }
                            else
                            {
                                if (!Roles.IsUserInRole(DnnUserInfo.Username, rolename.RoleName))
                                {
                                    Roles.AddUserToRole(DnnUserInfo.Username, rolename.RoleName);
                                }
                            }
                        }
                    }
                    else
                    {
                        //get the roles for this user and copy them to the YAF roles
                        DotNetNuke.Security.Roles.RoleController _DnnRoleController = new DotNetNuke.Security.Roles.RoleController();
                        ArrayList DnnRoleList;
                        DnnRoleList = _DnnRoleController.GetUserRoles(_portalSettings.PortalId, DnnUserInfo.UserID);
                        foreach (DotNetNuke.Entities.Users.UserRoleInfo rolename in DnnRoleList)
                        {
                          if (!Roles.RoleExists(rolename.RoleName))
                            {
                                Roles.CreateRole(rolename.RoleName);
                                Roles.AddUserToRole(DnnUser.UserName, rolename.RoleName);
                            }
                            else
                            {
                                if (!Roles.IsUserInRole(DnnUserInfo.Username, rolename.RoleName))
                                {
                                    Roles.AddUserToRole(DnnUserInfo.Username, rolename.RoleName);
                                }
                            }
                        }
                    }
  
This copies any roles assigned in DNN to the user to the YAF role provider.

Boskone - A DotNetNuke user.
RDSCC 
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