I'm working on an intranetproject in Umbraco. I use FormAuthentication to login the members. What i want to do is after a member is succesfull authenticated, is to check if there is a user account with the same username as the member and login this backenduser as well.
The member authenticates by Active Directory username and password (via a surfacecontroller).
The memberauthentication works well but I can not get the user authenticated after succesfull authenticating the member.
I have tried to do this with the code below but it doesn't work because when navigating to "/umbraco" the user still gets the loginform.
var user = Services.UserService.GetByUsername(model.Username);
if (user != null)
{
new HttpContextWrapper(System.Web.HttpContext.Current).CreateUmbracoAuthTicket(
new UserData(Guid.NewGuid().ToString())
{
Culture = user.Language,
Id = user.Id,
RealName = user.Name,
Username = user.Username
});
}
When using the code above, there is a cookie created called "UMB_UCONTEXT". Did I forgot something or is there another way to authenticate users programmatically only by username?
Thanks in avance!
Login member and user via FormAuthentication at once
Hi everybody,
I'm working on an intranetproject in Umbraco. I use FormAuthentication to login the members. What i want to do is after a member is succesfull authenticated, is to check if there is a user account with the same username as the member and login this backenduser as well. The member authenticates by Active Directory username and password (via a surfacecontroller).
The memberauthentication works well but I can not get the user authenticated after succesfull authenticating the member.
I have tried to do this with the code below but it doesn't work because when navigating to "/umbraco" the user still gets the loginform.
When using the code above, there is a cookie created called "UMB_UCONTEXT". Did I forgot something or is there another way to authenticate users programmatically only by username?
Thanks in avance!
iNETZO
The following code should work, it uses the built in Umbraco class 'WebSecurity'.
This works great, thanks!
is working on a reply...