How can I add a user to the asp_Users table in my LightSwitch application with non-forms based authentication?
I have an application with forms authentication, and I need another one without any authentication for registration.
I have set up the same application name for both sites.
Application type:
Client>Web
Server>IIS
If I have both applications with forms authentication everything works OK with this code:
Application.Current.User.AddPermissions(Permissions.SecurityAdministration);
var NewUser = this.DataWorkspace.SecurityData.UserRegistrations.AddNew();
NewUser.UserName = "XXXX";
NewUser.FullName = "XXXX XXXX";
NewUser.Password = "*********";
this.DataWorkspace.SecurityData.SaveChanges();
var UserRole = (from role in this.DataWorkspace.SecurityData.Roles
where role.Name == "Customer"
select role).FirstOrDefault();
if (UserRole != null)
{
var newRA = this.DataWorkspace.SecurityData.RoleAssignments.AddNew();
newRA.Role = UserRole;
newRA.User = NewUser;
this.DataWorkspace.SecurityData.SaveChanges();
}