Autthenticate user without password

Posted by Community Admin on 04-Aug-2018 09:55

Autthenticate user without password

All Replies

Posted by Community Admin on 28-Apr-2016 00:00

Hi,

I need to authenticate user without its password.

It is like an impersonation.

I am using the following code:

MembershipUser user = _userClientService.GetUserById(new Guid(id));
                if (user != null)
               
                    UserLoggingReason result = _authenticationService.AuthenticateUser(user.UserName, user.GetPassword());
                    
                    if (result == UserLoggingReason.Success)
                        Response.Redirect("/privado/dashboard/index", true);
               

_userClientService and _authenticationService are wrappers of sitefinity classes.

The problem is that I get an error on user.GetPassword()... Password recovery not enabled...

 

Thanks.

Posted by Community Admin on 28-Apr-2016 00:00

I edit my own post, this works:

 

MembershipUser user = _userClientService.GetUserById(new Guid(id));
                if (user != null)
               
                    User userAuth = new User();
                    SecurityManager.AuthenticateUser(user.ProviderName, user.UserName, false, out userAuth);
                    Response.Redirect("/privado/dashboard/index", true);
               

This thread is closed