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...DNN Platform (o...DNN Platform (o...DNN User Authentication from external systemDNN User Authentication from external system
New Post
3/24/2019 7:17 AM


Please, can you advise, how to create a valid user programmatically with
1) C# 
2) SQL

what is the best option from above? 1 or 2? We will use an external system to create users through other .NET websites. Non-DNN.

My current DNN website is DNN 9.2 (But can upgrade to DNN 9.3)

I appreciate your support for this.


New Post
3/25/2019 2:43 AM

To create DNN user programmatically please use DNN framework 'C#', instead of SQL. If you use core DNN methods, your code can be reused across multiple DNN versions v8+, v9+ etc. Below is a simple code snippet to create DNN user:

public UserInfo DnnUser_Create(string username, PortalSettings portalSettings)
//check if user already exists in DNN
DotNetNuke.Entities.Users.UserInfo _userInfo = DotNetNuke.Entities.Users.UserController.GetCachedUser(portalSettings.PortalId, username);

//user not exists in DNN, let's create him
if (_userInfo == null)
//create user
_userInfo = new UserInfo();
_userInfo.Username = username;
_userInfo.PortalID = portalSettings.PortalId;
_userInfo.Membership.Approved = true;
_userInfo.Membership.CreatedDate = DateTime.Now;
_userInfo.AffiliateID = DotNetNuke.Common.Utilities.Null.NullInteger;
_userInfo.Membership.Password = "MySecretPassword";

DotNetNuke.Security.Membership.UserCreateStatus userCreateStatus = UserController.CreateUser(ref _userInfo);
if (userCreateStatus != DotNetNuke.Security.Membership.UserCreateStatus.Success)
throw new Exception;

return _userInfo;
New Post
3/25/2019 2:49 AM
Then you can populate user profile properties according to following code snippet:

public UserInfo DnnUser_SyncProperties(UserInfo userInfo, int portalID)
if (userInfo != null)
userInfo.IsDeleted = false;
userInfo.Membership.Approved = true;
userInfo.AffiliateID = DotNetNuke.Common.Utilities.Null.NullInteger;

userInfo.DisplayName = "Displayname";
userInfo.FirstName = "FirstName";
userInfo.LastName = "LastName";
userInfo.Email = "email";

UserController.UpdateUser(portalID, userInfo);
New Post
3/25/2019 9:29 AM
Thank you very much or your great support.

If I use the mobile app to connect with this, how can I do this? Hope we cannot use the DNN framework for the mobile app.

(Is there a special reason not to recommend SQL user registration? It could be easier since we will use the same database for the web platform and for the mobile platform)
New Post
3/25/2019 2:58 PM
DNN is a website created at the top of .NET and can't work as mobile app. To connect it with native mobile app I suggest create WebAPI method inside DNN, accessible via REST protocol. In this scenario, all you need to do is set up HTTP channel between DNN and mobile app.
It's much easier work with DNN c# methods than SQL queries. For example to create user you need 'touch' four or more db tables. But if you decide work directly with database I encourage to utilize DNn SQL stored procedures to manage users.
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...DNN User Authentication from external systemDNN User Authentication from external system

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