More in this section

Forums / Developing with Sitefinity / Importing Users

Importing Users

4 posts, 0 answered
  1. Timothy Masson
    Timothy Masson avatar
    7 posts
    Registered:
    17 Oct 2004
    11 Jul 2007
    Link to this post
    Hi,
    I'm writing a simple usercontrol to import some users from an existing database to the Sitefinity DB.

    When I call :
    UserManager.Default.CreateUser(user.Customer_Number, user.password);
    I get the following error:

    System.NullReferenceException was unhandled by user code
      Message="Object reference not set to an instance of an object."
      Source="Telerik.DataAccess"
      StackTrace:
           at Telerik.DataAccess.AspnetProviders.User.VerifyObject()
           at Nolics.ORMapper.Base.OdbClassHelper.VerifyClass(IOdbClass cl)
           at Telerik.DataAccess.AspnetProviders.User.Nolics.ORMapper.Base.IOdbClass.BeginCommit()
           at Nolics.ORMapper.Base.Transaction.Commit(Boolean fCleanIfSuccess)
           at Nolics.ORMapper.Base.Transaction.Commit()
           at Telerik.DataAccess.AspnetProviders.TelerikMembershipProvider.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, Object providerUserKey, MembershipCreateStatus& status)
           at Telerik.Security.UserManager.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, Object providerUserKey, MembershipCreateStatus& status)
           at Telerik.Security.UserManager.CreateUser(String username, String password, String email)
           at Telerik.Security.UserManager.CreateUser(String username, String password)
           at UserImporter.butImport_Click(Object sender, EventArgs e) in c:\Program Files\telerik\Sitefinity3.0\WebSites\HadrianInfoCenter\UserControls\UserImporter.ascx.cs:line 70
           at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
           at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
           at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
           at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
           at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
           at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    Not sure what I'm doing wrong, but any light you can shed on this is appreciated. BTW the UserManager.Default can make a call to CreateRole(rolename) just fine, and writes the role appropriatley to the DB.

    Thanks in advance,
    -T
  2. Vlad
    Vlad avatar
    498 posts
    Registered:
    19 Jun 2017
    11 Jul 2007
    Link to this post
    Hi Timothy,

    Thank you for reporting this issue. We fixed it and updated your telerik points.
    Please use the following method instead:
    UserManager.Default.CreateUser(user.Customer_Number, user.password, string.Empty);


    Sincerely yours,
    Vlad
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Scott Wheeler
    Scott Wheeler avatar
    4 posts
    Registered:
    17 Aug 2004
    26 Nov 2008
    Link to this post
    I am trying to import users from another website, I have my list in an excel file (user id, password etc.) the password is unencrypted. Is there an easy way to import a table of users into telerik/sitefinity?
  4. Vlad
    Vlad avatar
    498 posts
    Registered:
    19 Jun 2017
    27 Nov 2008
    Link to this post
    Hi Scott,

    Sitefinity supports Membership Services. So, you could use the standard ASP.NET API to manage users. Also you could access the users directly from your existing data store if you implement your custom Membership and Role providers. Here are some links:
    http://msdn.microsoft.com/en-us/library/6tc47t75.aspx
    http://msdn.microsoft.com/en-us/library/aa478949.aspx
    http://www.odetocode.com/Articles/427.aspx
    http://weblogs.asp.net/scottgu/archive/2006/02/24/ASP.NET-2.0-Membership_2C00_-Roles_2C00_-Forms-Authentication_2C00_-and-Security-Resources-.aspx

    If you still want to import the users, probably the easiest way is to implement a function which reads the data from the excel table and for each record create new user with the following method:

    UserManager.Default.CreateUser(username, password, email);

    Hope this is helpful.

    Best regards,
    Vlad
    the Telerik team
Register for webinar
4 posts, 0 answered