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...Building ExtensionsBuilding ExtensionsOther Extension...Other Extension...Adding DNN-Users from a custom schedulerAdding DNN-Users from a custom scheduler
Previous
 
Next
New Post
2/19/2014 12:54 PM
 

Hi Community,

I am trying to add a number of users & roles from a web service regularly polled by my custom scheduler. The problem is that I get an exception when trying to create the user.

Here is the code I'm using:

Dim uinfo As DotNetNuke.Entities.Users.UserInfo = DotNetNuke.Entities.Users.UserController.GetUserByName(portalId, row.Field(Of String)("LoginEmail"))
                    If uinfo Is Nothing Then
                        ' user does not exist -> create new user
                        uinfo = New DotNetNuke.Entities.Users.UserInfo()
                        With uinfo
                            .Username = row.Field(Of String)("LoginEmail")
                            .Email = row.Field(Of String)("LoginEmail")
                            .FirstName = row.Field(Of String)("FirstName")
                            .LastName = row.Field(Of String)("LastName")
                            .DisplayName = row.Field(Of String)("FirstName")
                            .IsSuperUser = False
                            .PortalID = portalId
                            With .Profile
                                .PreferredLocale = DotNetNuke.Services.Localization.LocaleController.Instance.GetCurrentLocale(portalId).Code
                                .PreferredTimeZone = TimeZoneInfo.Local
                                .FirstName = row.Field(Of String)("FirstName")
                                .LastName = row.Field(Of String)("LastName")
                            End With
                            With .Membership
                                .Password = row.Field(Of String)("LoginPassword")
                                .Approved = row.Field(Of Boolean)("LoginActive")
                                .CreatedDate = DateTime.Now
                                .IsOnLine = False
                            End With
                        End With

                        Try
                            Dim createResult As DotNetNuke.Security.Membership.UserCreateStatus = DotNetNuke.Entities.Users.UserController.CreateUser(uinfo)
                            If createResult <> DotNetNuke.Security.Membership.UserCreateStatus.Success Then
                                Throw New Exception("Creation failed. " & createResult.ToString())
                            End If
                        Catch ex As Exception
                            With uinfo
                                Throw New Exception(String.Format("username: {0}, ex: {1}", .Username, ex.ToString()))
                            End With
                        End Try
                    Else
                        ' user exists -> set status
                        uinfo.Membership.Approved = row.Field(Of Boolean)("LoginActive")
                        DotNetNuke.Entities.Users.UserController.UpdateUser(portalId, uinfo)
                    End If

 

Here is the exception:

System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.Security.Membership.AspNetMembershipProvider.CreateUser(UserInfo& user) at DotNetNuke.Entities.Users.UserController.CreateUser(UserInfo& user) at AcumenOnline.Scheduler.LoginScheduler.InsertData() at AcumenOnline.Scheduler.LoginScheduler.InsertData() at AcumenOnline.Scheduler.LoginScheduler.ExecuteDataPolling() at AcumenOnline.Scheduler.LoginScheduler.DoWork()


Has anyone an idea where this could be coming from? The "uinfo" object can't be "Nothing" as I am checking on that before and create a new object just before I try and add this.


Thanks in advance,

Nils

 
New Post
2/19/2014 5:02 PM
 
I believe this is the issue you're seeing - https://dnntracker.atlassian.net/brow... (which has been fixed in 7.2.2)

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
2/20/2014 2:17 AM
 
DNN 7.2.2 isnt out yet, any idea on a release date.

In the bug link you posted above it says its resolved which I am guessing just means you have noted the issue and fixed in upcomming release. Does that mean the posters suggestion of changing PortalController.GetCurrentPortalSettings() to PortalSettings(portalid) worked so we could just manually patch in our 7.2.1 release?

 
New Post
2/20/2014 8:24 AM
 
we're due to codefreeze 7.2.2 tomorrow so it will be out after QA testing (usually 10 days or so). As to the suggested workaround, I don't see that working as the issue was an internal function that didn't take any passed portalsettings - you can see the changes at https://github.com/dnnsoftware/Dnn.Pl... if you feel confident in making core updates.

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
2/20/2014 10:29 PM
 

Thank you very much this helped me solve the issue by just the two modifications to the core api.

 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsOther Extension...Other Extension...Adding DNN-Users from a custom schedulerAdding DNN-Users from a custom scheduler


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.

Content Layout

Subscribe to DNN Digest

DNN Digest is our monthly email newsletter. It highlights news and content from around the DNN ecosystem, such as new modules and themes, messages from leadership, blog posts and notable tweets. Keep your finger on the pulse of the ecosystem by subscribing.  


Copyright 2017 by DNN Corp Terms of Use Privacy
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out