Hi Niel,
Your strategy appears sound. When integrating the UpmMembershipProvider with DNN some time ago, I also was forced to decorate it to address some incompatibilities between DNN and Commerce Server.
With respect to (a), find below the code that I use to create a user when (1) remote validation succeeds and (2) local validation fails. Note that it ultimately calls base.CreateUser versus this.CreateUser, because this.CreateUser is overridden and would cause an infinite loop. Also, an empty PreferredLocale will cause problems down the road -- so do not leave it blank.
protected UserCreateStatus CreateLocalUser(int portalId, string userName, string password, UserInfo user)string portalName = PortalController.GetCurrentPortalSettings().PortalName;var Webservices = WebserviceFactory.Create();var LegacyUser = Webservices.GetUserData(PortalName, userName, password);if(user == null)throw new ArgumentNullException("user");else if(string.IsNullOrEmpty(userName))throw new ArgumentNullException("userName");// Hydrate the UserInfo object
user.PortalID = portalId;
user.FirstName = LegacyUser.FirstName;
user.LastName = LegacyUser.LastName;
user.Email = userName;
user.Profile.InitialiseProfile(portalId);
user.Username = userName;
user.Membership.Password = password;
user.Membership.Approved = True;
user.AffiliateID = LegacyUser.UserID;
user.DisplayName =
user.Profile.Unit =
user.Profile.Street = LegacyUser.StreetAddress;
user.Profile.City = LegacyUser.City;
user.Profile.Region =
user.Profile.PostalCode = LegacyUser.ZipCode;
user.Profile.Country =
user.Profile.Telephone = LegacyUser.Telephone;
user.Profile.Cell = LegacyUser.Cell;
user.Profile.Fax =
user.Profile.IM =
user.Profile.Website =
user.Profile.PreferredLocale =
user.Profile.TimeZone = 0;
user.Profile.FirstName = user.FirstName;
user.Profile.LastName = user.LastName;
string.Format(CultureInfo.InvariantCulture, "{0} {1}", LegacyUser.FirstName, LegacyUser.LastName).Trim();string.Empty;string.Empty;"USA";string.Empty;string.Empty;string.Empty;"en-US";if(string.IsNullOrEmpty(user.DisplayName)) user.DisplayName = userName;if(string.IsNullOrEmpty(user.FirstName)) user.FirstName = "Unknown";if(string.IsNullOrEmpty(user.LastName)) user.LastName = "Unknown";if(string.IsNullOrEmpty(user.Email)) user.Email = string.Empty;// Create the DNN user
}
Regarding (b), I do not believe I've added a user to a role in code before. Your code looks solid, and would be my initial approach as well. During user creation, UserController executes similar code (Components/Users/UserController.vb on or about line177), but does not appear to make a call to controller.UpdateRole. My guess is that's your bad call. DNN also seems to generally use Null.NullDate for the date parameters.
Hope this helps!
Brandon
return base.CreateUser(user);
{