Developer forum

Forum » Development » Extranet user login programatically

Extranet user login programatically

Ryan Jeppesen
Reply

Im having difficulties logging in a user through my code.

 

Im creating a user in my code and this works fine. After creating the user i want to login the user and redirect him to a proteched page. But the user isent logged in correctly, the user is prompted for login on the protected page.

 

My code:

 

        private void LoginToDynamicWeb(string _cUserName, string _cPassword)
        {
            Dynamicweb.Security sec = new Dynamicweb.Security();
            sec.ExtranetLogin(_cUserName, _cPassword, true);
            HttpContext.Current.Response.Redirect("/LoggedIn.aspx");
        }

How can i login the user through code?


Replies

 
Morten Snedker
Reply

You are doing it the right way. Please check the group membership of the user. If the user is not member of an extranet group, he will not be logged in.

 

Also, try popping in a

Dynamicweb.Base.wa("User is logged in: " + sec.UserLoggedIn.ToString());

to verify if the user is actually logged in. (wa = write alert).

 

Regards /Snedker

 

 
Ryan Jeppesen
Reply

Hi Morten

 

Thx for your quick reply.

 

UserLoggedIn returns false. The user is member of a group. In table AccessUser the user have @256@ in AccessUserGroups. 256 is a valid extranet group.

 
Ryan Jeppesen
Reply
This post has been marked as an answer
Found the error. I had forgotten to set a DateTime to AccessUserValidFrom and AccessUserValidTo. 
Votes for this answer: 1

 

You must be logged in to post in the forum