Products

Solutions

Resources

Partners

Community

About

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0MichaelMichael's Portal Login
Previous
 
Next
New Post
12/1/2008 5:27 PM
 

Hello,

I have no clue about the inner workings of DNN and Michael's idea of being able to authenticate a user in one portal against the user details in a 'Master' portal would solve some problems for me, so I installed the module and it does almost what I want, but I'm not knowledgeable enough to make the amendments to the code to get it to work how I need it to.

The module currently confirms that the user is valid and then retrieves the roles that the user belongs to and creates userrole records in the target portal.  The problem for me is that the userroles are created with expiry dates a long way off using a DateTime.MaxValue parameter value, and I make use of the dates to allow access to content.  I have copied the current code below, can someone please help me modify this code so that the userrole records are created with the same effectiveDate and Expiry date that they have in the source portal.

        #region UpdateUserInTheCurrentPortal
        private void UpdateUserRoles(UserInfo objAuthenticationPortalUserInfo)
        {
            UserInfo objUserInfo = UserController.GetUserByName(PortalId, objAuthenticationPortalUserInfo.Username);
            RoleController RoleController = new RoleController();
            RoleInfo RoleInfo;

            // First remove the user from all roles they are in
            foreach (string strRole in objUserInfo.Roles)
            {
                RoleInfo = RoleController.GetRoleByName(PortalId, strRole);
                if (!(RoleInfo == null))
                {
                    if (RoleController.CanRemoveUserFromRole(PortalSettings, objUserInfo.UserID, RoleInfo.RoleID))
                    {
                        RoleController.DeleteUserRole(PortalId, objUserInfo.UserID, RoleInfo.RoleID);
                    }
                }
            }

            // Add the user to the roles that they are in in the Authentication portal           
            foreach (string strRole in objAuthenticationPortalUserInfo.Roles)
            {
                RoleInfo = RoleController.GetRoleByName(PortalId, strRole);
                if (!(RoleInfo == null))
                {
                    RoleController.AddUserRole(PortalId, objUserInfo.UserID, RoleInfo.RoleID, DateTime.MaxValue);
                }
            }

        }
        #endregion

Any help very gratefully accepted

Many thanks

Barry

 
New Post
12/3/2008 3:26 PM
 

No promises but this shoud work:

                if (!(RoleInfo == null))
                {
                     // Set the date to the date you want
                     DateTime dtExpDate = Convert.ToDateTime("12/5/2008");
                     RoleController.AddUserRole(PortalId, objUserInfo.UserID, RoleInfo.RoleID, dtExpDate);
                }

 



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
New Post
12/3/2008 4:12 PM
 

Thanks for replying Michael, that makes sense.

I'm trying to get to a stage where I can have other related portals using the authentication portal for all role/membership management. So if I am managing all the roles from within the authentication portal, how would I duplicate the UserRole information (including EffectiveDate and ExpiryDate) from the authentication portal into a record for the target portal (providing that there's a security role with the same name in the target portal) ?

Many thanks

Barry

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0MichaelMichael's Portal Login


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out