Issue with programmatically logging in membership users

  • I'm running into a case where login code that works in some environments, and has been working in production for a while, is not working in a new development environment. I'm wondering if there's an obvious reason why this method of programmatically logging someone in wouldn't work (or if there's a better method).  We're doing this in code because our SSO is technically handling the authentication -- if SSO says the user's good, we just log them into Ektron and send them on to whatever page they were trying to access.

    The code:

    UserManager um = new UserManager();
    System.Web.HttpContext currentContext = System.Web.HttpContext.Current;
    UserData ud = um.Login(strUsername, strPassword, currentContext.Request.ServerVariables["SERVER_NAME"]);
    if (Ektron.Cms.Framework.Context.UserContextService.Current.IsLoggedIn)
    //never runs, because IsLoggedIn always returns false

    Username and password are definitely right (sending the wrong info for either generates a clear error message).  The value in SERVER_NAME looks right to me -- it's the name of the developer VM, same as on my old developer VM which works fine with this code -- but I don't know what it's supposed to get compared to, so I can't be sure.  No errors are generated on the Login() call, and the correct user's info is returned to the ud object, but the UserContextService still says they aren't logged in.

    Any insight would be appreciated, thanks!

    Posted 1/24/2017 @ 6:38 PM
    • Posted by jrowland
    • Joined on 1/24/2017
    • 39 total posts

What Do You Think of our New Design?


Have more to say? We’d love to hear it!