How can I create a dotnetnuke user account from the command line correctly?

I am trying to create a high-speed command-line program for one-time import of users from the old system (without DNN) to the new system. However, a NullReferenceExceptiongets a throw in the following line of code:

        var user = new UserInfo();
        user.PortalID = portalId;
        user.FirstName = firstName;

An exception is thrown in this last line. I know that this code works when run in a module, as it is part of the library that I use. I believe this is a mistake because the class UserInforelies on information normally installed in a web environment.

Is there any way to do this? I really do not want it to be like a module running on a production site.

+3
source share
1 answer

, UserController UserInfo. - - DNN. DLL DNN DNN .

, UserInfo object FirstName , FirstName , . DNNProfileProvider, FileBasedCachingProvider SqlDataProvider . UserInfo, ProfileController.GetUserProfile. NullReferenceException.

DNN 5.6.3:

UserInfo.vb

<SortOrder(1), MaxLength(50), Required(True)> _
Public Property FirstName() As String
    Get
        Return Profile.FirstName
    End Get
    Set(ByVal Value As String)
        Profile.FirstName = Value
    End Set
End Property

<Browsable(False)> _
Public Property Profile() As UserProfile
    Get
        'implemented progressive hydration
        'this object will be hydrated on demand
        If _Profile Is Nothing Then
            _Profile = New UserProfile
            ProfileController.GetUserProfile(Me)
        End If
        Return _Profile
    End Get
    Set(ByVal Value As UserProfile)
        _Profile = Value
    End Set
End Property
+1

All Articles