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