kentico_helenag
-
9/9/2008 4:01:58 AM
RE:CustomEventHandler
Unfortunately, it is needful to use two databases and one record for each user in both of them.
You could copy the records from your external database programmatically and update them according one of them (or maybe use some external tool to synchronize the databases).
The sample code would be similar to the one from Developer’s Guide. It could look like this (logical structure):
if (userInfo != null) { if (userInfo.IsExternal = true) { If !(values of userInfo correspond to record of external database) { Update userInfo; } } return userInfo; } // Sample external user credentials UserInfo usr = null; // Not authenticated, authenticate from the external source if (UserName && Password correspond to any record of your external database) { // Create base user record if user found usr = new UserInfo(); usr.IsExternal = true; usr.UserName = UserName; usr.UserPassword = Password; usr.Enabled = true;
copy information from your external database – e.g. usr.Email, usr.FullName, ... // 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["external role"] = 0; } // Return the user info return usr;
Best regards, Helena Grulichova
|