Automatically login messenger with site registered users

Last post 10-21-2009, 4:10 AM by voodzzz. 5 replies.
Sort Posts: Previous Next
  •  10-07-2009, 4:48 PM 56199

    Automatically login messenger with site registered users


    I'm planning on using the messenger for the registered members of our site.
    I'd like to launch messenger in a new window for the site logged in user so that the user is automatically logged in to messenger.
    Could you explain how I can do this?
     
    Cheers
    Mike
  •  10-08-2009, 2:36 AM 56208 in reply to 56199

    Re: Automatically login messenger with site registered users

    Hi mike99c,

    After you integrate Cute Messenger with your membership database, the user will automatically logged in the messenger after they logged in your site.
     
    And the new messenger is open in a new window now.
     
    you can test here http://dotnetdate.com/.
     
    Integrate membership database, you can refer to below
     
     
    Regards,
     
    Ken
  •  10-08-2009, 5:51 AM 56219 in reply to 56208

    Re: Automatically login messenger with site registered users

    Hi Ken,
     
    Thanks for your reply.
     
    I may not have explained my requirement clearly so will just explain again in more detail.
     
    I am developing a website using ASP classic. The website has its own SQL Server database where all the members are registered. I also intend to write into the web messenger database to store the same account details so they can be accessed by web messenger.
     
    What I require is to be able to allow members to log into the website I am devloping, but once logged in I want them to launch the web messenger.
     
    My question is, what do I pass into the link to web messenger to enable a particular account to be logged in so that the account holder can use Messenger right away? I don't want them to sign into web messenger again.
     
    Regards
     
    Mike
  •  10-11-2009, 3:35 PM 56322 in reply to 56219

    Re: Automatically login messenger with site registered users

    I've looked at the Login page, Login.aspx.
    What I want to do is bypass this login page and call the launch messenger directly passing in the username with a known username from the database.
    I have tried calling (from Login.aspx)
       FormsAuthentication.RedirectFromLoginPage("user451", false);
    with the rest of btnLogin_Click commented out.
     
    This appears to work OK, logs you so that you get the username at the top of the page and a logout button, but when I select Messenger, it launches - but it is not logged in - and I get a anonymous login not allowed message.
     
    Any advice much appreciated.
  •  10-12-2009, 11:38 AM 56353 in reply to 56199

    Re: Automatically login messenger with site registered users

    Mike,
     
    First you need to integrate your own membership database into Cute Chat.
     
     
    Second you need to call JavaScript funtion to open web messenger.
     
    There are two methods to open web messenger.
     
    Open Messenger in dialog
    Open Messenger in page
     
    Please check the source code of this page:
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  10-21-2009, 4:10 AM 56545 in reply to 56353

    Re: Automatically login messenger with site registered users

    I also is having hard time integrating it to our current social network website. I am developing it using Visual studio. I tried following the integration overview, but I was really confused.
     
    Can you elaborate this part:
     
    CuteChat.ChatProvider.Instance = new MyChatProvider();
    CuteChat.ChatSystem.Start(new CuteChat.AppSystem()); 
     
    Below is the complete code
    1. public class cutechatClass : System.Web.UI.Page  
    2. {  
    3.     public static String ConnectionString  
    4.     {  
    5.         get  
    6.         {  
    7.             return ConfigurationManager.ConnectionStrings["dbCuteChat"].ToString();  
    8.         }  
    9.     }  
    10.     public static DateTime OnlineTimeoutTime  
    11.     {  
    12.         get  
    13.         {  
    14.             Int32 iTimeoutSecond = Int32.Parse(System.Configuration.ConfigurationSettings.AppSettings["OnlineTimeout"]);  
    15.             return DateTime.Now.AddSeconds(0 - iTimeoutSecond);  
    16.         }  
    17.     }  
    18.   
    19.     public static void UpdateLastLoginTime(String username, DateTime lastLoginTime)  
    20.     {  
    21.         SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbCuteChat"].ToString());  
    22.         SqlCommand cmd = new SqlCommand("update Users set LastLoginTime=@LastLoginTime where Username=@Username", conn);  
    23.   
    24.         SqlParameter paraLastLoginTime = cmd.Parameters.Add("@LastLoginTime", SqlDbType.DateTime);  
    25.         paraLastLoginTime.Value = lastLoginTime;  
    26.   
    27.         SqlParameter paraUsername = cmd.Parameters.Add("@Username", SqlDbType.NVarChar);  
    28.         paraUsername.Value = username;  
    29.   
    30.         try  
    31.         {  
    32.             conn.Open();  
    33.             cmd.ExecuteNonQuery();  
    34.         }  
    35.         finally  
    36.         {  
    37.             conn.Close();  
    38.         }  
    39.     }  
    40.   
    41.     public static String[] GetRolesOfUser(String username)  
    42.     {  
    43.         SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbCuteChat"].ToString());  
    44.         SqlCommand cmd = new SqlCommand("select RoleName from UserRole where Username=@Username", conn);  
    45.   
    46.         SqlParameter paraUsername = cmd.Parameters.Add("@Username", SqlDbType.NVarChar);  
    47.         paraUsername.Value = username;  
    48.   
    49.         try  
    50.         {  
    51.             conn.Open();  
    52.   
    53.             SqlDataReader reader = cmd.ExecuteReader();  
    54.             ArrayList roles = new ArrayList();  
    55.             while (reader.Read())  
    56.             {  
    57.                 roles.Add(reader.GetString(0));  
    58.             }  
    59.   
    60.             return (String[])roles.ToArray(typeof(String));  
    61.         }  
    62.         finally  
    63.         {  
    64.             conn.Close();  
    65.         }  
    66.     }  
    67.   
    68.   
    69.   
    70.     public static String[] GetAllRoles()  
    71.     {  
    72.         SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbCuteChat"].ToString());  
    73.         SqlCommand cmd = new SqlCommand("select RoleName from Roles order by RoleName", conn);  
    74.   
    75.         try  
    76.         {  
    77.             conn.Open();  
    78.             SqlDataReader reader = cmd.ExecuteReader();  
    79.             ArrayList result = new ArrayList();  
    80.             while (reader.Read())  
    81.             {  
    82.                 result.Add(reader.GetString(0));  
    83.             }  
    84.             return (String[])result.ToArray(typeof(String));  
    85.         }  
    86.         finally  
    87.         {  
    88.             conn.Close();  
    89.         }  
    90.     }  
    91.   
    92.   
    93.     public static void AddUserToRole(String roleName, String username)  
    94.     {  
    95.   
    96.         if (cutechatClass.IsUserInRole(roleName, username))  
    97.         {  
    98.             return;  
    99.         }  
    100.   
    101.         SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbCuteChat"].ToString());  
    102.         SqlCommand cmd = new SqlCommand("Insert into UserRole (Username, RoleName) values (@Username, @RoleName)", conn);  
    103.   
    104.         SqlParameter paraUsername = cmd.Parameters.Add("@Username", SqlDbType.NVarChar);  
    105.         paraUsername.Value = username;  
    106.   
    107.         SqlParameter paraRoleName = cmd.Parameters.Add("@RoleName", SqlDbType.NVarChar);  
    108.         paraRoleName.Value = roleName;  
    109.   
    110.         try  
    111.         {  
    112.             conn.Open();  
    113.             cmd.ExecuteNonQuery();  
    114.         }  
    115.         catch  
    116.         {  
    117.             return;  
    118.         }  
    119.         finally  
    120.         {  
    121.             conn.Close();  
    122.         }  
    123.     }  
    124.   
    125.     public static void RemoveUserFromRole(String roleName, String username)  
    126.     {  
    127.         SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbCuteChat"].ToString());  
    128.         SqlCommand cmd = new SqlCommand("delete from UserRole where (Username=@Username) and (RoleName=@RoleName)", conn);  
    129.   
    130.         SqlParameter paraUsername = cmd.Parameters.Add("@Username", SqlDbType.NVarChar);  
    131.         paraUsername.Value = username;  
    132.   
    133.         SqlParameter paraRoleName = cmd.Parameters.Add("@RoleName", SqlDbType.NVarChar);  
    134.         paraRoleName.Value = roleName;  
    135.   
    136.         try  
    137.         {  
    138.             conn.Open();  
    139.             cmd.ExecuteNonQuery();  
    140.         }  
    141.         finally  
    142.         {  
    143.             conn.Close();  
    144.         }  
    145.     }  
    146.   
    147.     public static void RemoveUserFromAllRoles(String username)  
    148.     {  
    149.         SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbCuteChat"].ToString());  
    150.         SqlCommand cmd = new SqlCommand("delete from UserRole where (Username=@Username)", conn);  
    151.   
    152.         SqlParameter paraUsername = cmd.Parameters.Add("@Username", SqlDbType.NVarChar);  
    153.         paraUsername.Value = username;  
    154.   
    155.         try  
    156.         {  
    157.             conn.Open();  
    158.             cmd.ExecuteNonQuery();  
    159.         }  
    160.         finally  
    161.         {  
    162.             conn.Close();  
    163.         }  
    164.     }  
    165.   
    166.     public static Boolean IsUserInRole(String roleName, String username)  
    167.     {  
    168.         SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbCuteChat"].ToString());  
    169.         SqlCommand cmd = new SqlCommand("select COUNT(Username) from UserRole where (Username=@Username) and (RoleName=@RoleName)", conn);  
    170.   
    171.         SqlParameter paraUsername = cmd.Parameters.Add("@Username", SqlDbType.NVarChar);  
    172.         paraUsername.Value = username;  
    173.   
    174.         SqlParameter paraRoleName = cmd.Parameters.Add("@RoleName", SqlDbType.NVarChar);  
    175.         paraRoleName.Value = roleName;  
    176.   
    177.         try  
    178.         {  
    179.             conn.Open();  
    180.             return Convert.ToInt32(cmd.ExecuteScalar()) > 0;  
    181.         }  
    182.         finally  
    183.         {  
    184.             conn.Close();  
    185.         }  
    186.     }  
    187.   
    188.   
    189.     public cutechatClass()  
    190.     {  
    191.         CuteChat.ChatProvider.Instance = new CuteChat.ChatProvider();  
    192.         CuteChat.ChatSystem.Start(new CuteChat.AppSystem());  
    193.     }  

View as RSS news feed in XML