+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Autthenticate user without password

Autthenticate user without password

2 posts, 2 answered
  1. Kiko
    Kiko avatar
    5 posts
    Registered:
    07 May 2012
    28 Apr
    Link to this post

    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.

    Answered
  2. Kiko
    Kiko avatar
    5 posts
    Registered:
    07 May 2012
    28 Apr in reply to Kiko
    Link to this post

    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);
                    }

    Answered
2 posts, 2 answered