Peter
-
1/20/2009 9:34:04 PM
User authentication
Hi, I've modified the CustomSecurityHandler OnAuthentication method to get users from our external database using example from Kentico documentation.
After successfully inserting a new user, I cannot log in the user as the OnAuthentication object userInfo returns null. I'm guessing it has something to do with the password but can't see what the problem is.
If anyone can help, I would greatly appreciate it.
Here is the code I've used.
// Create base user record if user found usr = new UserInfo(); usr.IsExternal = true; usr.UserName = username; usr.FullName = "John Bloke"; usr.Email = jbloke@mymail.com; usr.Enabled = true;
// Init user sites and roles if requested Hashtable rolesTable = new Hashtable(); string siteName = CMSContext.CurrentSite.SiteName;
// Assign user to the current site usr.SitesRoles[siteName.ToLower()] = rolesTable;
// Add new role "external role" and assign it to the user rolesTable["RegisteredUser"] = 0;
// Create new user UserInfoProvider.SetUserInfo(usr);
// Set user password UserInfoProvider.SetPassword(usr, password);
|