Login Problem

Last post 05-29-2007 10:26 PM by XiaoYong Dai – MSFT. 6 replies.

Sort Posts:

  • Login Problem

    05-24-2007, 2:17 AM
    • Loading...
    • moonsrisun
    • Joined on 05-24-2007, 6:10 AM
    • Posts 7

     Hi

         I have created Inhouse asp.net application. i have used Registration and login control. i have created one account. Account name is "Sri". I can logged on my account and i could access my application. In the same time i can log on to my application from another machine using the same User Name. How to prevent the other's should not use the username which is already logged in. Please help me

     

    Thanks

    S.Srinivasan.

     


     

  • Re: Login Problem

    05-24-2007, 6:21 AM
    • Loading...
    • reteep
    • Joined on 06-30-2005, 9:27 AM
    • Germany
    • Posts 188

    Create an Event for the Login Control, something like OnLogin and check for this:

    if (User.Identity.IsOnline){
    .. show error ..
    return;
    }

  • Re: Login Problem

    05-24-2007, 8:18 AM
    • Loading...
    • moonsrisun
    • Joined on 05-24-2007, 6:10 AM
    • Posts 7

     Thanks. But i am unable to see the property

    if( User.Identity.IsOnline )

    {

    }

     

    IsOnline is not available. Please help me.

     

     

     

  • Re: Login Problem

    05-24-2007, 10:48 AM
    Answer
    • Loading...
    • mosessaur
    • Joined on 07-11-2002, 6:40 PM
    • Cairo
    • Posts 352

    Upon user login, check if the user alreay online or not. you can do something similar to this:
    MembershipUser user = Membership.GetUser("Sri");
    if(user.IsOnline)
      //Prevent to user from loggin in again.

    You need to review remarks about IsOnline Property on MSDN:

    User is considered online if the current date and time minus the UserIsOnlineTimeWindow property value is earlier than the LastActivityDate for the user.

    I hope this would give you a support

    Muhammad M. Mosa Soliman
    Software Engineer
    Moses's Blog
  • Re: Login Problem

    05-26-2007, 2:13 AM
    • Loading...
    • moonsrisun
    • Joined on 05-24-2007, 6:10 AM
    • Posts 7

    I Wrote the code like this

            string user = (Login1.FindControl("UserName") as TextBox).Text;
            MembershipUser GetUser = Membership.GetUser(user);
            if (GetUser.IsOnline)
            {
                Literal ll = (Login1.FindControl("FailureText") as Literal);
                ll.Text = "This User Already Logged in!";
            }

    This code returns true (GerUser.IsOnline) for all the UserName. That means if i enter "Sri" as username it returns true. In which place i have to write this code.. already i checked in the following Events

    Login1_Authenticate and LoggingIn 

    Help me how to proceed.

    Thaks

    S.Srinivasan 

     

  • Re: Login Problem

    05-26-2007, 12:35 PM
    Answer
    • Loading...
    • hypercode
    • Joined on 07-15-2006, 2:42 PM
    • Posts 214

    Try this in your Login1_LoggingIn event. It's in VB, you obviously have to translate to C#.

    Good Luck!

    In your Login1_LoggingIn event:

    Dim theUser As String = Login1.UserName
    If (Membership.GetUser(theUser).IsOnline = True) Then
       
    e.Cancel = True
       
    lblBad.Text = "You are already logged in!"
    End If

     

  • Re: Login Problem

    05-29-2007, 10:26 PM
    Answer

    moonsrisun:

    This code returns true (GerUser.IsOnline) for all the UserName. That means if i enter "Sri" as username it returns true. In which place i have to write this code.

    Hi 

    You can also specify whether you want GetUser to update the last-activity date/time stamp for the user being retrieved with the userIsOnline parameter. Of the GetUser overloads that do not take a userIsOnline parameter, Membership.GetUser implicitly updates the last-activity date/time stamp for the user.

    So, I think you'd try to use the Membership.GetUser overload that specify the userIsOnline=false,

    Best Regards
    XiaoYong Dai
    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Page 1 of 1 (7 items)
Microsoft Communities
Page view counter