Home
Cute Chat / Web Messenger Developer's Guide Prev Page Prev Page
Getting Started
Features of Cute Chat
Features of Web Messenger
Chat Requirements
Web Messenger Requirements
License
Deployment & Integration
Installing Chat/Messenger Standalone
Community Server CS 2.1 Integration
Community Server CS 2.0 Integration
Community Server CS 1.x Integration
Dotnetnuke 4.x Integration
Dotnetnuke 3.x Integration
Dotnetnuke 2.x Integration
IbuySpy(C#) Integration
IbuySpy(VB) Integration
Snitz forum Integration
Rainbow Portal Integration
FAQ
Overview
Run Cute Chat from different folder
Customization
Set up Cute Chat banner ads
Set up Web Messenger banner ads
Add a time stamp to each message
Embed mode
Run Cute Chat in embed mode
Run Web Messenger in embed mode
Localization
Specify the custom culture name
Add a new language file
Oracle and Access
Use Oracle as Data Source
Use Access as Data Source
Integration with an existing user membership database.
Integration with an existing user membership database (C#).
Integration with an existing user membership database (VB).
General Installation Instructions
Cute Chat

Integration with an existing user membership database (VB)

Integration with an existing user membership database (VB)


Before you get started, you need to understand the 'UniqueName' in CuteChat. In CuteChat, UniqueName means the unique data of your user. Depending on how you implement the user system, in some systems, the best unique data is the user ID; in some system, every user have a unique account name; some systems like MSN, the unique data is the user email. It could be string(username, email), integer(user ID) or GUID.

Unzip the integration package zip file and open cs/Global.asax file.

Implement IHttpApplicationConnectionStringProvider interface and Let CuteChat know the database connection string


In this step, you need to implement one simple method:

'Retrieves the Cute Chat database connection string
Public Function GetConnectionString(ByVal user As CuteSoft.Chat.UserIdentity) As String Implements CuteSoft.Chat.IHttpApplicationConnectionStringProvider.GetConnectionString
Code Example

Public Function GetConnectionString(ByVal user As CuteSoft.Chat.UserIdentity) As String Implements CuteSoft.Chat.IHttpApplicationConnectionStringProvider.GetConnectionString

    Return System.Configuration.ConfigurationSettings.AppSettings("SiteSqlServer")

End Function

Implement IHttpApplicationUserAdapter interface and Let CuteChat know who has logged in the website


In this step, you need to implement one simple method:

'Retrieves the unique identity of the current user
Public Function GetUserIdentity() As CuteSoft.Chat.UserIdentity Implements CuteSoft.Chat.IHttpApplicationUserAdapter.GetUserIdentity

Code Example

Public Function GetUserUniqueName() As String Implements CuteSoft.Chat.IHttpApplicationUserAdapter.GetUserUniqueName

        If Not Context.Request.IsAuthenticated Then
            Return Nothing
        End If

        'email
        Return Context.User.Identity.Name
 End Function
    
 Public Function GetUserIdentity() As CuteSoft.Chat.UserIdentity Implements CuteSoft.Chat.IHttpApplicationUserAdapter.GetUserIdentity
        Dim un As String = GetUserUniqueName()
        If un Is Nothing Then
            Return CuteSoft.Chat.UserIdentity.CreateNull()
        End If

        Return New CuteSoft.Chat.UserIdentity(un, Nothing, Context.Request.UserHostAddress)
 End Function

Implement IHttpApplicationDataProvider interface and Let CuteChat know your membership database information


In this step, you need to implement five methods:

'Check the user is an administrator or not.
Public Function IsAdministrator(ByVal useruniquename As String) As Boolean Implements CuteSoft.Chat.IHttpApplicationDataProvider.IsAdministrator

Code Example
Public Function IsAdministrator(ByVal useruniquename As String) As Boolean Implements CuteSoft.Chat.IHttpApplicationDataProvider.IsAdministrator

        Dim udb As New UsersDB
        Dim email As String = useruniquename

        Dim roles As String() = udb.GetRoles(email)
        Return Array.IndexOf(roles, "Admins") <> -1

End Function


'Return user's display name
Public Function GetUserDisplayName(ByVal useruniquename As String) As String Implements CuteSoft.Chat.IHttpApplicationDataProvider.GetUserDisplayName

Code Example

Public Function GetUserDisplayName(ByVal useruniquename As String) As String Implements CuteSoft.Chat.IHttpApplicationDataProvider.GetUserDisplayName
        Dim udb As New UsersDB
        Dim email As String = useruniquename

        Dim sdr As SqlDataReader = udb.GetSingleUser(email)
        Try
            Dim hasrecord = sdr.Read()
            If (hasrecord) Then
                Return sdr.GetString(sdr.GetOrdinal("Name"))
            End If
        Finally
            sdr.Close()
        End Try

        Return "(Unknown)"

  End Function

'Retrieves all the user's unique names in the database. 
 Public Function ListUserUniqueName() As String() Implements CuteSoft.Chat.IHttpApplicationDataProvider.ListUserUniqueName

Code Example

 Public Function ListUserUniqueName() As String() Implements CuteSoft.Chat.IHttpApplicationDataProvider.ListUserUniqueName
        Dim udb As New AdminDB
        Dim sdr As SqlDataReader = udb.GetUsers()
        Try
            Dim list As New ArrayList
            Dim pos As Integer = sdr.GetOrdinal("Email")
            Do While sdr.Read
                list.Add(sdr.GetString(pos))
            Loop
            Return CType(list.ToArray(GetType(String)), String())
        Finally
            sdr.Close()
        End Try
  End Function

'Return an array of user names containing the input string.
Public Function SearchUserUniqueNameByDisplayName(ByVal userDisplaName As String) As String() Implements CuteSoft.Chat.IHttpApplicationDataProvider.SearchUserUniqueNameByDisplayName

Code Example

   Public Function SearchUserUniqueNameByDisplayName(ByVal userDisplaName As String) As String() Implements CuteSoft.Chat.IHttpApplicationDataProvider.SearchUserUniqueNameByDisplayName

        Dim emptystrings(0) As String

        If userDisplaName Is Nothing Then
            Return New String(0) {}
        End If

        userDisplaName = userDisplaName.ToLower()

        If userDisplaName = String.Empty Then
            Return emptystrings
        End If

        Dim names As New System.Collections.ArrayList

        Dim cmd As New SqlCommand
        cmd.Connection = New SqlConnection(GetConnectionString(Nothing))
        cmd.CommandText = "SELECT email FROM Users WHERE Name LIKE
'%'+@p0+'%'"
        cmd.Parameters.Add("@p0", SqlDbType.NVarChar, 100)
        cmd.Parameters("@p0").Value = userDisplaName
        cmd.Connection.Open()
        Try
            Dim sdr As SqlDataReader = cmd.ExecuteReader()
            Try
                Do While sdr.Read()
                    names.Add(sdr.GetString(0)) '0-Email
                Loop
            Finally
                sdr.Close()
            End Try
        Finally
            cmd.Connection.Close()
        End Try

        Return CType(names.ToArray(GetType(String)), String())
  End Function


'Check the user is a lobby admin or not (only for integrated room).
Public Function IsLobbyAdmin(ByVal useruniquename As String, ByVal lobby As CuteSoft.Chat.CuteChatLobby) As Boolean Implements CuteSoft.Chat.IHttpApplicationDataProvider.IsLobbyAdmin

Code Example
 Public Function IsLobbyAdmin(ByVal useruniquename As String, ByVal lobby As CuteSoft.Chat.CuteChatLobby) As Boolean Implements CuteSoft.Chat.IHttpApplicationDataProvider.IsLobbyAdmin
        Return False
 End Function

 

Implement IHttpApplicationSupportLogin interface and Let CuteChat can verify the operator's credentials


In this step, you need to implement two methods:

'Check the user is an operator or not (only for live support).
Public Function SupportLogin(ByVal username As String, ByVal password As String) As Boolean Implements CuteSoft.Chat.IHttpApplicationSupportLogin.SupportLogin


Code Example

 Public Function SupportLogin(ByVal username As String, ByVal password As String) As Boolean Implements CuteSoft.Chat.IHttpApplicationSupportLogin.SupportLogin
        If username Is Nothing Or username.Trim() = "" Then
            Return False
        End If
        If password Is Nothing Or password = "" Then
            Return False
        End If
        username = username.Trim()

        Dim email As String = username

        Dim uniquename As String = email
        If CuteSoft.Chat.ChatApi.FindOperator(uniquename) Is Nothing Then
            Return False
        End If

        Dim udb As New UsersDB
        Dim security As New PortalSecurity

        Dim name As String = udb.Login(email, security.Encrypt(password))

        If name Is Nothing Or name = String.Empty Then
            Return False
        End If

        System.Web.Security.FormsAuthentication.SetAuthCookie(email, False, "/")

        Return True

   End Function


//Fire when the conversation start.
public void SupportInit()

Code Example
Public Sub SupportInit() Implements CuteSoft.Chat.IHttpApplicationSupportLogin.SupportInit
        ''nothing
End Sub



The CHM file was converted to HTML by chm2web software.