Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

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

HomeHomeDevelopment and...Development and...Getting StartedGetting StartedChanges in behaviour of UserControler object.Changes in behaviour of UserControler object.
Previous
 
Next
New Post
1/23/2011 8:50 AM
 
I am debugging some dnn pre-5 code. The code does basically this:
                Dim db As New UserController
                Dim u As UserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo() 'Always use this function becouse it is saved on current context
                If Not u Is Nothing Then
                    Dim usern As String = u.Username
                    Dim cl As String = MyLocale
                    u.Profile.PreferredLocale = cl
                    u.Membership.Username = usern
                    DotNetNuke.Entities.Users.UserController.UpdateUser(DotNetNuke.Common.GetPortalSettings().PortalId, u)
                End If
What is happening is that UserInfo.Username is stored into UserInfo.Membership.Username. All the rest makes sense to me.

I would have no problem with this construct, were it not for the warning that Public Property Username as String is obsolete since DNN 5.1. Is there anyone that can demystify this for me?
Maybe a blog that explains something? My big fat book of DNN knowledge says nothing about this, itself been written pre-5.1.

____________________________________
The one-eyed in the land of the blind.
 
New Post
1/23/2011 5:11 PM
 

I'm not sure that I see the purpose of the following two lines anyway since the result will be to asign the Username value back to itself:

Dim usern As String = u.Username
u.Membership.Username = usern

In DNN 5.1 and later, it is the UserInfo.Membership.Username which was deprecated, not UserInfo.Username. In the code for the deprecated Username property (UserMembership.vb) we see:

<Obsolete("Deprecated in DNN 5.1")> _
<Browsable(False)> Public Property Username() As String
Get
   Return _User.Username
End Get
Set(ByVal Value As String)
_User.Username = Value
End Set
End Property

Which simply gets and sets the UserInfo.Username property.

One other point to watch here is that GetCurrentUserInfo will allways return a non null UserInfo object even for the unauthenticated user. Rather than checking for a null UserInfo object I would check for u.UserId <> -1.

 



Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
1/23/2011 11:41 PM
 
I better get myself braced for one hell of a debug-ride (but the extension is well worth the effort!).There are a lot of warnings about depreciated functions in DNN 5 but most come with a suggestion for a new function offering the same functionality, so I think I'll be able to work myself through that.

One more question: If I would install the sources, would that be dropping the source in the dnn folder and editing vbproj or is there another procedure to set it up?

____________________________________
The one-eyed in the land of the blind.
 
New Post
1/24/2011 12:15 AM
 
William Severance wrote:

I'm not sure that I see the purpose of the following two lines anyway since the result will be to asign the Username value back to itself:

 

 
Yep. Remember this is pre-DNN 5 leftover. So the question would be wether it made sense under DNN 3 and 4. A lot of these things are probably work-arounds for bugs in earlier code.

Another explenation is that this is a remainder of a debug session: check if this is the correct user. But then, why write it back?

I'll find the answer, trust me.


____________________________________
The one-eyed in the land of the blind.
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Getting StartedGetting StartedChanges in behaviour of UserControler object.Changes in behaviour of UserControler object.


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