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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0I can UPDATE but canI can UPDATE but can't INSERT new records on custom module
Previous
 
Next
New Post
3/17/2008 6:18 PM
 

Alright, I have a custom Authentication Provider that I've been working on. On login, it connects to a UNIX server and authenticates the user. Then if that is successful, it checks the Users table for the same user, updates some info from a custom table and Logs them in if they exist. If they don't exist in the Users table, it creates them using info from a custom table.

Here's my code:

 

//Get your information from the external database

 

try

{

 

 

 

 

 

 

{

dealerNumber = response.Substring(response.IndexOf(

}

 

 

{

 

 

 

 

 

WebClient webClient = new WebClient();Stream webResponse = webClient.OpenRead(_AuthenticationWebURL+enteredUsername+"~"+enteredPassword);StreamReader reader = new StreamReader(webResponse);string response = reader.ReadToEnd();string dealerNumber = string.Empty;if (response.Length > 10)"<title>")+7,5);if (dealerNumber != "00000")KochAirDealersController objDCtrl = new KochAirDealersController();KochAirDealersInfo objDealer = objDCtrl.Get(Convert.ToInt32(dealerNumber));KochAirUsersController objUCtrl = new KochAirUsersController();KochAirUsersInfo objUser = objUCtrl.GetByUserName(enteredUsername);//Determine if we have the user

 

{

dnnUser.PortalID = _portalSettings.PortalId;

dnnUser.Username = enteredUsername;

dnnUser.FirstName = dnnUser.Profile.FirstName = objUser.FirstName;

dnnUser.LastName = dnnUser.Profile.LastName = objUser.LastName;

dnnUser.Email = objUser.Email;

 

if (dnnUser != null)//oUser.Profile.ProfileProperties["DealerNumber"] = objDealer.DealerId.ToString();

 

//oUser.Profile.ProfileProperties["DealerName"] = objDealer.Name;

 

//oUser.Profile.ProfileProperties["DealerLine"] = objDealer.Line;

 

//oUser.Profile.ProfileProperties["DealerLocation"] = objDealer.LocationId;

dnnUser.IsSuperUser =

dnnUser.Membership.Username = enteredUsername;

dnnUser.Membership.Password = enteredPassword;

dnnUser.Membership.Email = objUser.Email;

dnnUser.Membership.Approved =

dnnUser.Membership.LastLoginDate =

 

 

false;true;DateTime.Now;UserController.UpdateUser(this.PortalId, dnnUser);//Log the user in!

RaiseAuthenticationEvent(dnnUser, enteredUsername,

}

 

UserLoginStatus.LOGIN_SUCCESS, true, "");else

{

 

//Response.Redirect(objUser.FirstName);

 

 

//Add user into the system

dnnUser =

dnnUser.PortalID =

dnnUser.IsSuperUser =

dnnUser.FirstName = objUser.FirstName;

dnnUser.LastName = objUser.LastName;

dnnUser.Email = objUser.Email;

dnnUser.Username = enteredUsername;

dnnUser.DisplayName =

 

new UserInfo();this.PortalId;false;String.Concat(objUser.FirstName, " ", objUser.LastName);//Set Membership

DotNetNuke.Entities.Users.

oNewMembership.Approved =

oNewMembership.CreatedDate = System.

oNewMembership.Email = objUser.Email;

oNewMembership.IsOnLine =

oNewMembership.Username = enteredUsername;

oNewMembership.Password = enteredPassword;

 

UserMembership oNewMembership = new DotNetNuke.Entities.Users.UserMembership();true;DateTime.Now;false;//Bind membership to user

dnnUser.Membership = oNewMembership;

 

//Add the user, ensure it was successful

 

{

 

if (UserCreateStatus.Success == UserController.CreateUser(ref dnnUser))//Log them in

RaiseAuthenticationEvent(dnnUser, enteredUsername,

}

 

UserLoginStatus.LOGIN_SUCCESS, true, "");else

{

DotNetNuke.Services.Exceptions.

}

}

 

}

 

Exceptions.ProcessModuleLoadException(this, new Exception("Unable to create user"));else

{

 

 

//Not valid User

RaiseAuthenticationEvent(

}

}

 

{

DotNetNuke.Services.Exceptions.

}

 

My problem is that it works perfectly is the user already exists in the Users table. It authenticates, updates and then logs them in. BUT, if the user is't in the Users table, it won

t create them. Just gives me the exception. I don't understand. I have went line by line in debug and each value is beig set, everything works perfectly until it hits the "if (UserCreateStatus.Success == UserController.CreateUser(ref dnnUser))." then it just skips the creation and moves onto the exception.

Can anyone give me some insight to what I have done wrong here??? I have been looking for 8 hrs now and still nothing.

Any help is greatly appreciated!

new UserInfo(), enteredUsername, UserLoginStatus.LOGIN_FAILURE, false, Localization.GetString("InvalidLogin", this.LocalResourceFile));catch (Exception ex)Exceptions.ProcessModuleLoadException(this, ex);

 
New Post
3/18/2008 1:57 AM
 

Sorry for all the space in the code. I didn't realize until too late.

 
New Post
3/18/2008 1:32 PM
 

NEVERMIND! I found it, finally!

Ok, just for reference, first, my passwords were not hitting the min length set in web.config. Once I figured that out, I was able to get it to insert, but still was throwing the exception, "Unable to create user." So I went and looked around and it seems there is a bug in UserCreateStatus method in DNN 4.8.0. Something was causing an Unexpected Error and the Create Status was catching that and not the Success. Once I updated to 4.8.1 it worked perfectly.

 

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0I can UPDATE but canI can UPDATE but can't INSERT new records on custom module


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