Ronald wrote
well, i'd rather like to develop the module myself because its in the learning trajectory im in. however what i am trying to achieve is this:
User A registers on the site and enters his ID
the website validates the ID with the help of an external database
ID gets accepted and written into the users profile (however, only admins should be able to change the ID)
User A logs in
ID that is linked to the user gets pulled from the DNN database
The website validates the ID again (to check wether it hasnt expired, this is also entered in the external db)
ID gets accepted and the user can reach the "inner" website
when the ID's get rejected however they must state accordingly "Invalid" or "Expired"
i hope that is enough information, i already have a ValidateID process which checks the database for the ID's. this uses a sqlExecuteScalar to retreive two values
string found (this done to make it more global, e.g. Label1.text = ValidateID(strID) so it states the errormessage if any)
boolean valid
Okay... I see this being possible in one of two ways:
- Custom Authentication Provider
- Custom Login and/or Registration module
Lets talk about the two methods and how they might be accomplished. Using a custom authentication provider is probably overkill because for the most part you still want to use everything in the DNN authentication provider with exception that you want to add a step. You'd still need a way to provide for entering in that ID upon registration and then your authentication provider could use that value behind the scenes and do whatever it needs to do.
Alternatively you could go with a custom login/registration module. I like this approach because you can hand-tailor your registration module to be formatted the way you want, ask for the fields you want, etc. You could still use *all* the DNN code behind the scenes to accomplish the registration and that is good. What I'd do is have it fire off the code to check the ID upon registration and validate it... if it is good, allow the registration to complete and save their ID as a custom profile field. In a nutshell, here is some code (copied straight out of my own production code) that saves a new user and stores something in their profile.
DotNetNuke.Security.Membership.UserCreateStatus crStat;
// add user first
DotNetNuke.Entities.Users.UserInfo info = new DotNetNuke.Entities.Users.UserInfo();
info.Profile.InitialiseProfile(this.PortalId);
info.DisplayName = textDisplayName.Text;
info.Email = textEmail.Text;
info.FirstName = textFirstName.Text;
info.LastName = textLastName.Text;
info.PortalID = this.PortalId;
info.Username = textUserName.Text;
info.Membership.Password = textPassword.Text;
info.Membership.Username = textUserName.Text;
info.Membership.Email = textEmail.Text;
info.Membership.Approved = false;
info.Profile.PreferredLocale = "en-US";
info.Profile.FirstName = textFirstName.Text;
info.Profile.LastName = textLastName.Text;
info.Profile.SetProfileProperty("Employee_ID", textEmployeeId.Text);
crStat = DotNetNuke.Entities.Users.UserController.CreateUser(ref info);
So now lets assume you have that. If you have your own login module you can validate the login with the ID (load the user and then use the info.Profile.GetPropertyValue("someproperty") to retrieve it). You can use DotNetNuke.Entities.Users.UserController.ValidateUser to ensure credentials are correct and, if so, then use DotNetNuke.Entities.Users.UserController.UserLogin to log them in (and then you should redirect them to a new page or the same page so the cookies get loaded in and used).
Hope that gives you a starting point. Any more questions, ask away.
DotNetNuke.Entities.Users.UserInfo info =