Voici les deux méthodes auxquelles vous faites référence à partir du code source de la version actuelle 5.4.2. D'après ce que je peux voir, les diffs sont 1) GetUser est dépréciée 2) GetUser semble hydrater manuellement les rôles, les notes suggèrent que les utilisateurs individuels sont hydratés automatiquement
ici est l'ancienne méthode
''' -----------------------------------------------------------------------------
''' <summary>
''' GetUser retrieves a User from the DataStore
''' </summary>
''' <remarks>
''' </remarks>
''' <param name="portalId">The Id of the Portal</param>
''' <param name="userId">The Id of the user being retrieved from the Data Store.</param>
''' <param name="isHydrated">A flag that determines whether the user is hydrated.</param>
''' <param name="hydrateRoles">A flag that instructs the method to automatically hydrate the roles</param>
''' <returns>The User as a UserInfo object</returns>
''' <history>
''' </history>
''' -----------------------------------------------------------------------------
<Obsolete("Deprecated in DNN 5.1. Not needed any longer for single users due to autohydration")> _
Public Shared Function GetUser(ByVal portalId As Integer, ByVal userId As Integer, ByVal isHydrated As Boolean, ByVal hydrateRoles As Boolean) As UserInfo
Dim user As UserInfo = GetUserById(portalId, userId)
If hydrateRoles Then
Dim controller As DotNetNuke.Security.Roles.RoleController = New DotNetNuke.Security.Roles.RoleController
user.Roles = controller.GetRolesByUser(userId, portalId)
End If
Return user
End Function
et voici la nouvelle méthode
''' -----------------------------------------------------------------------------
''' <summary>
''' Get the current UserInfo object
''' </summary>
''' <returns>The current UserInfo if authenticated, oherwise an empty user</returns>
''' <history>
''' [cnurse] 05/23/2005 Documented
''' </history>
''' -----------------------------------------------------------------------------
Public Shared Function GetCurrentUserInfo() As UserInfo
If (HttpContext.Current Is Nothing) Then
If Not (Thread.CurrentPrincipal.Identity.IsAuthenticated) Then
Return New UserInfo
Else
Dim _portalSettings As PortalSettings = PortalController.GetCurrentPortalSettings
If Not _portalSettings Is Nothing Then
Dim objUser As UserInfo = GetCachedUser(_portalSettings.PortalId, Thread.CurrentPrincipal.Identity.Name)
If Not objUser Is Nothing Then
Return objUser
Else
Return New UserInfo
End If
Else
Return New UserInfo
End If
End If
Else
Dim objUser As UserInfo = CType(HttpContext.Current.Items("UserInfo"), UserInfo)
If Not objUser Is Nothing Then
Return objUser
Else
Return New UserInfo
End If
End If
End Function
est-ce toute aide?
grâce
Mark Breen
Irlande
1987 BMW R80GS
Salut Mark Breen, C'est exactement ce que je cherche. Merci beaucoup ... –