Imports Microsoft.VisualBasic
Imports System.Collections
Imports CuteChat
Public Class MyChatProvider
Inherits CuteChat.ChatProvider
'....................................
Public Overrides Function GetConnectionString() As String
Return System.Configuration.ConfigurationManager.AppSettings.Get("ChattInlogg")
End Function
'....................................
Public Overrides Function GetLogonIdentity() As CuteChat.AppChatIdentity
If Not HttpContext.Current.Request.IsAuthenticated Then
Return Nothing
End If
Dim id As FormsIdentity = TryCast(HttpContext.Current.User.Identity, FormsIdentity)
Dim ticket As FormsAuthenticationTicket = id.Ticket
Dim userDataString As String = ticket.UserData
Dim userDataPieces As String() = userDataString.Split(",".ToCharArray())
Return New CuteChat.AppChatIdentity(userDataPieces(1), False, ToUserId(userDataPieces(0)), HttpContext.Current.Request.UserHostAddress)
End Function
'....................................
Public Overrides Function GetUserInfo(ByVal loginName As String, ByRef nickName As String, ByRef isAdmin As Boolean) As Boolean
Dim id As FormsIdentity = TryCast(HttpContext.Current.User.Identity, FormsIdentity)
Dim ticket As FormsAuthenticationTicket = id.Ticket
Dim userDataString As String = ticket.UserData
Dim userDataPieces As String() = userDataString.Split(",".ToCharArray())
loginName = userDataPieces(0)
nickName = userDataPieces(1)
If loginName = "1011" Then
isAdmin = True
Return True
Else
isAdmin = False
Return False
End If
End Function
'....................................
Public Overrides Function FindUserLoginName(ByVal nickName As String) As String
Return True
End Function
'....................................
Public Overloads Overrides Function ValidateUser(ByVal username As String, ByVal password As String) As Boolean
Return True
End Function
End Class