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

HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...How to create a new  user programmaticallyHow to create a new user programmatically
Previous
 
Next
New Post
5/22/2012 4:54 AM
 

Hi.

I need a way to   programmatically add an user to  DNN 6.1.3. I've done some research and i've seen a lot of code.

My current code looks like this:

DotNetNuke.Entities.Users.UserInfo objUser = new DotNetNuke.Entities.Users.UserInfo();
                UserMembership oNewMembership = new UserMembership(objUser);


                objUser.Membership = oNewMembership;


                objUser.AffiliateID = Null.NullInteger;
                objUser.Email = "user@email.com";
                objUser.PortalID = 0;
                objUser.Username = "UserName";
                objUser.DisplayName = "Display Name";
                objUser.IsSuperUser = false;
                objUser.Email = "user@email.com";


                objUser.Membership.UpdatePassword = false;
                objUser.Membership.Approved = true;


                objUser.FirstName = "";
                objUser.LastName = "";

The last two lines of my code give the following error: "Object reference not set to an instance of an object."

at DotNetNuke.Common.Globals.get_Status() in C:\PortalIB\DotNetNuke\Library\Common\Globals.cs:line 567
   at DotNetNuke.Entities.Portals.PortalController.GetEffectivePortalId(Int32 portalId) in C:\PortalIB\DotNetNuke\Library\Entities\Portals\PortalController.cs:line 2118
   at DotNetNuke.Entities.Profile.ProfileController.GetEffectivePortalId(Int32 portalId) in C:\PortalIB\DotNetNuke\Library\Entities\Profile\ProfileController.cs:line 177
   at DotNetNuke.Entities.Profile.ProfileController.GetUserProfile(UserInfo& user) in C:\PortalIB\DotNetNuke\Library\Entities\Profile\ProfileController.cs:line 452
   at DotNetNuke.Entities.Users.UserInfo.get_Profile() in C:\PortalIB\DotNetNuke\Library\Entities\Users\UserInfo.cs:line 257
   at DotNetNuke.Entities.Users.UserInfo.set_FirstName(String value) in C:\PortalIB\DotNetNuke\Library\Entities\Users\UserInfo.cs:line 138
   at something.Reg.RegiUse(String username, String password, CheckBoxList CheckBoxListRoles, String nome, String email, Label LabelMsg) in C:\PortalIB\Portal\Util

Does anyone have an ideia of what is going on? 


Thanks




 
New Post
5/22/2012 12:13 PM
 
the wiki has an example that should help - http://www.dotnetnuke.com/Resources/Wiki/Page/Create-a-New-User-and-Add-to-Specific-Role-Programatically.aspx

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
5/23/2012 10:06 AM
 

Thanks for the suggestion. Do you know how to do that from an external  website, for instance, some website in an iframe? 


Thanks

 
New Post
5/23/2012 1:47 PM
 
you can use http://iweb.codeplex.com/ to make a remote call-or in 6.2.0 you can use the new services framework

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
6/26/2012 8:40 AM
 
Can you link me to the services framework? This sounds cooooool. :)
 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...How to create a new  user programmaticallyHow to create a new user programmatically


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