More in this section
Forums / Developing with Sitefinity / Autthenticate user without password

Autthenticate user without password

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 2 answered
  1. Kiko
    Kiko avatar
    5 posts
    Registered:
    07 May 2012
    28 Apr 2016
    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 2016 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