Forbidden: You don't have permission to access Admin Console.

Last post 12-11-2008, 6:11 AM by sonicaab. 9 replies.
Sort Posts: Previous Next
  •  04-21-2008, 1:46 AM 39535

    Forbidden: You don't have permission to access Admin Console.

    Hi there.
     
    Hope you can help me. I've downloaded and installed the Integration package in order to integrate Chat with my current website.
     
    I followed the instructions and added the following to my /global.asax file:
     
         Public Overrides Sub Init()
            MyBase.Init()
           
            If Not CuteChat.ChatSystem.HasStarted Then
                CuteChat.ChatProvider.Instance = New CuteChatMembership()
                CuteChat.ChatSystem.Start(New CuteChat.AppSystem())
            End If
        End Sub
     
    I then implemeted my CuteChatMembership class in a vb file located in my App_Code folder. The gist of it is below:
     
    Imports System.Configuration
    Imports System.Web
    Imports System.Web.Security
    Imports CuteChat

    Public Class CuteChatMembership
        Inherits CuteChat.ChatProvider

        Public Overrides Function GetConnectionString() As String
            Return ConfigurationManager.ConnectionStrings("CuteChat").ConnectionString
        End Function

        Public Overrides Function FindUserLoginName(ByVal nickName As String) As String
            Return HttpContext.Current.User.Identity.Name
        End Function

        Public Overrides Function GetLogonIdentity() As AppChatIdentity
            'need to find the information of current user. Return null if user is anonymous.
            Dim thisUser As New LoggedInUser(HttpContext.Current.User.Identity.Name)
            If thisUser.LoggedIn Then
                Return New AppChatIdentity(HttpContext.Current.User.Identity.Name, False, thisUser.AccountID, HttpContext.Current.Request.UserHostAddress)
            Else
                Return Nothing
            End If
        End Function

        Public Overrides Function GetUserInfo(ByVal loginName As String, ByRef nickName As String, ByRef isAdmin As Boolean) As Boolean
            isAdmin = True
            nickName = loginName
            Return True
        End Function
        Public Overrides Function ValidateUser(ByVal loginName As String, ByVal password As String) As Boolean
            If System.Web.Security.Membership.ValidateUser(loginName, password) Then
                System.Web.Security.FormsAuthentication.SetAuthCookie(loginName, False)
                Return True
            Else
                Return False
            End If
        End Function
    End Class
     
     
    So as you can see, I'm making sure that every user has Admin access. Unfortunately, I get the following error when trying to go to /CuteSoft_Client/CuteChat/ChatAdmin/ :
    Forbidden: You don't have permission to access Admin Console. Please login as admin.
     
     I know that most of it is working, because I get redirected to /login.aspx if I haven't logged into the website first. However, that isAdmin variable seems to be not being set.
     
    Any help will be greatly appreciated.
     

  •  04-21-2008, 10:12 AM 39558 in reply to 39535

    Re: Forbidden: You don't have permission to access Admin Console.

    Chage:
     
    Public Overrides Function GetUserInfo(ByVal loginName As String, ByRef nickName As String, ByRef isAdmin As Boolean) As Boolean
            isAdmin = True
            nickName = loginName
            Return True
        End Function
     
    to:
     
    Public Overrides Function GetUserInfo(ByVal loginName As String, ByRef nickName As String, ByRef isAdmin As Boolean) As Boolean
            If Not HttpContext.Current.Request.IsAuthenticated Then
                Return False
            End If
            isAdmin = True
            nickName = loginName
            Return True
        End Function

    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

  •  04-21-2008, 6:06 PM 39591 in reply to 39558

    Re: Forbidden: You don't have permission to access Admin Console.

    Hi Adam,
     
    Thank you for the prompt reply. Unfortunately, I'm still getting the same problem. It is detecting whether I am logged in fine, it's just not giving me admin privledges.
     
    Code pasted below for your reference:
     
    Imports System.Configuration
    Imports System.Web
    Imports System.Web.Security
    Imports CuteChat

    Public Class CuteChatMembership
        Inherits CuteChat.ChatProvider

        Public Overrides Function GetConnectionString() As String
            Return ConfigurationManager.ConnectionStrings("CuteChat").ConnectionString
        End Function

        Public Overrides Function FindUserLoginName(ByVal nickName As String) As String
            Return HttpContext.Current.User.Identity.Name
        End Function

        Public Overrides Function GetLogonIdentity() As AppChatIdentity
            'need to find the information of current user. Return null if user is anonymous.
            Dim thisUser As New LoggedInUser(HttpContext.Current.User.Identity.Name)
            If thisUser.LoggedIn Then
                Return New AppChatIdentity(HttpContext.Current.User.Identity.Name, False, thisUser.AccountID, HttpContext.Current.Request.UserHostAddress)
            Else
                Return Nothing
            End If
        End Function

        Public Overrides Function GetUserInfo(ByVal loginName As String, ByRef nickName As String, ByRef isAdmin As Boolean) As Boolean
            If Not HttpContext.Current.Request.IsAuthenticated Then
                Return False
            End If
            isAdmin = True
            nickName = loginName
            Return True
        End Function
        Public Overrides Function ValidateUser(ByVal loginName As String, ByVal password As String) As Boolean
            Dim objAccount As New Techflare.Mongoose.Core.Account
            If objAccount.Login(loginName, password, String.Empty) Then
                FormsAuthentication.SetAuthCookie(loginName, False)
                FormsAuthentication.GetRedirectUrl(loginName, False)
                Return True
            Else
                Return False
            End If
        End Function
    End Class

  •  04-21-2008, 10:17 PM 39595 in reply to 39591

    Re: Forbidden: You don't have permission to access Admin Console.

    If a user has loggined your membership database, can he/she log in the chat room directly?


    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

  •  04-21-2008, 11:04 PM 39603 in reply to 39535

    Re: Forbidden: You don't have permission to access Admin Console.

    Hmm, not sure exactly what you mean.
     
    What I've done is exactly as follows: 
     
    - Downloaded http://cutesoft.net/downloads/folders/chat_current_releases/entry28676.aspx
    - Followed the guide: http://cutesoft.net/ASP.NET+Chat/Developer-Guide/ (first "Installing Chat/Messenger Standalone", then "Membership Database Integration")
    - Tried going to /CuteSoft_Client/CuteChat/ChatAdmin
    - Was redirected to /login.aspx. So I logged in via my website's login facility.
    - Tried going back to ChatAdmin.
    - Received error about no admin permission.
     
    I haven't done any set-up of the chat itself as I can't log into the Admin console at all.
     
     
  •  04-22-2008, 10:40 AM 39662 in reply to 39603

    Re: Forbidden: You don't have permission to access Admin Console.

    1. Create a chat room first using the standlalone version.
     
    2. Make sure the user can login chat room using the same username of your system.
     
    3. Work on this admin part later.

    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

  •  05-08-2008, 12:32 AM 40202 in reply to 39662

    Re: Forbidden: You don't have permission to access Admin Console.

    Hi Adam,
     
    I was able to create a room by directly editing the database, and added an embedded chat room on one of my pages. When I go to it, it uses my login name from the website successfully and I can chat fine. However, I still cannot access the admin functionality. Please advise.
     
    And while I'm here, just a different question: Is it possible to allow Guest users in the custom integrated version of the chat, i.e. people who just want to chat with a temp username and they don't want to go through the hassle of creating an account on my website?

  •  05-08-2008, 5:06 PM 40227 in reply to 40202

    Re: Forbidden: You don't have permission to access Admin Console.

    techflare,
     
    1.
    You need to check the following implementation:
     
    public override bool GetUserInfo(string loginName, ref string nickName, ref bool isAdmin)
    {
           return false , if the loginName is invalid.
           otherwise set the nickName and isAdmin , and return ture
    }
     
    2.

    If you allow anoymous users join your chat room, it will use the user name like: Guest_c319.
     
     
     

    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

  •  05-08-2008, 7:59 PM 40230 in reply to 40227

    Re: Forbidden: You don't have permission to access Admin Console.

    Hi Adam,
     
    I've confirmed that it's as follows:
     
        Public Overrides Function GetUserInfo(ByVal loginName As String, ByRef nickName As String, ByRef isAdmin As Boolean) As Boolean
            'return false , if the loginName is invalid.
            'otherwise set the nickName and isAdmin , and return ture
            nickName = "test"
            isAdmin = True
        End Function

  •  12-11-2008, 6:11 AM 46802 in reply to 40230

    Re: Forbidden: You don't have permission to access Admin Console.

    I fixed this issue by overriding the IsAdministrator function:

            Public Overrides Function IsAdministrator(ByVal userid As String) As Boolean
     
                Dim userGUID As Guid = New Guid(userid)
                Dim LoginName As String = Membership.GetUser(userGUID).UserName
                Dim IsUserInRole As Boolean = Roles.IsUserInRole(LoginName, "ChatAdmin")
                If IsUserInRole Then
                    Return True
                Else
                    Return False
                End If
     
            End Function
     
    Hope this helps.
View as RSS news feed in XML