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

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsOther Extension...Other Extension...Importing and updating users in codeImporting and updating users in code
Previous
 
Next
New Post
8/26/2012 1:48 PM
 

I have found some code on how to create users in C# .

But I need to find a way to check if the user already exists by username or email - if he is already registered, I would like to be able to change his password and other data by code.

Below is the code used to create a new user:

private void AddUser()
{

DotNetNuke.Entities.Users.UserInfo objUser = new DotNetNuke.Entities.Users.UserInfo();
objUser.AffiliateID = Null.NullInteger;
objUser.Email = "user@email.com";
objUser.FirstName = "FirstName";
objUser.IsSuperUser = false;
objUser.LastName = "LastName";
objUser.PortalID = this.PortalId;
objUser.Username = "UserName";
objUser.DisplayName = "Display Name";

objUser.Membership.Password = "your_password";
//please check in web.config requirements for your password (length, letters, etc)
objUser.Membership.Approved = true;
objUser.Membership.Email = "user@email.com";
objUser.Membership.Username = objUser.Username;
objUser.Profile.Country = "Your Country";
objUser.Profile.Street = "Street";
objUser.Profile.City = "City";
objUser.Profile.Region = "Region";
objUser.Profile.PostalCode = "PostalCode";
objUser.Profile.Unit = "Unit";
objUser.Profile.Telephone = "Telephone";
objUser.Profile.FirstName = objUser.FirstName;
objUser.Profile.LastName = objUser.LastName;

DotNetNuke.Security.Membership.UserCreateStatus objCreateStatus =
DotNetNuke.Entities.Users.UserController.CreateUser(ref objUser);

if (objCreateStatus == DotNetNuke.Security.Membership.UserCreateStatus.Success)
{
  //everything fine
}
else
{
  //simple show error
  lblError.Text = objCreateStatus.ToString();
}

}

 
New Post
9/10/2012 8:01 AM
 
Doesnt anyone at all have any ideas on how to update users via code??
 
New Post
9/14/2012 12:14 AM
 
use the userinfo or usercontroller or membership (I dont remember exactly.... maybe UserController.GetUser) to fetch user ...... I think it will return -1 if user doesnt exist ..............if u fetch a user successfully by that username then user exists and you can update that user's info through the dnn api methods
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsOther Extension...Other Extension...Importing and updating users in codeImporting and updating users in code


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