Login Form return OK, but lgoin failed!

Last post 06-02-2011, 9:24 PM by pjs75. 18 replies.
Sort Posts: Previous Next
  •  05-22-2009, 3:27 PM 52435

    Login Form return OK, but lgoin failed!

    I get this error when I try to login with the cute live support ...
     
    somebody knows the answer ?
  •  05-25-2009, 1:29 PM 52485 in reply to 52435

    Re: Login Form return OK, but lgoin failed!

    Which version are you using?
     
    Is your site online? If so, can you send the URL, FTP access to me at Adam@CutgeSoft.net?

    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-27-2009, 1:30 AM 52540 in reply to 52435

    Re: Login Form return OK, but lgoin failed!

    Hi,
     
    I think you haven't wrote the ChatProvider , or made mistake on the implementation code.
     
    Please post your code, we will help you fix it.
     
    Regards,
    Terry
     
  •  08-29-2009, 4:34 PM 55171 in reply to 52540

    Re: Login Form return OK, but lgoin failed!

    I'm having the same problem "Login Form return OK, but login failed!", here is my chat provider code:  (when I use the default provider in the web.config and alter the code to use the default one instead of the secondary one, I can connect fine but this provider using an admin instance doesn't work.)  What am I missing here?
     

    //-----------------------------------------------------------------------
    // <summary>AspNetChatProvider is to provide access to the CuteChat services for live support.</summary>

    namespace Web.Mvc
    {

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using CuteChat;

    /// <summary>
    /// AspNetChatProvider - class to provide access to the CuteChat services for live support.
    /// </summary>
    public class AspNetChatProvider : ChatProvider
    {
    /// <summary>
    /// Gets the connection string.
    /// </summary>
    /// <returns>Connection String.</returns>
    public override string GetConnectionString()
    {
    return System.Configuration.ConfigurationManager.ConnectionStrings["TruLiveSupportConnection"].ConnectionString;
    }

    /// <summary>
    /// Gets the logon identity.
    /// </summary>
    /// <returns>Override of AppChatIdentity.</returns>
    public override AppChatIdentity GetLogonIdentity()
    {
    if (System.Web.Security.Membership.Provider.Name == "AspNetSqlMembershipProviderLiveSupport")
    {
    //this I think is where the problem is...
    System.Web.Security.
    MembershipUser user = System.Web.Security.Membership.GetUser();
    if (user != null && user.IsApproved)
    {
    return new AppChatIdentity(user.UserName, false, ToUserId(user.UserName), HttpContext.Current.Request.UserHostAddress);
    }
    }
    return null;
    }

    /// <summary>
    /// Finds the name of the user login.
    /// </summary>
    /// <param name="nickName">Name of the nick.</param>
    /// <returns>Override Username String.</returns>
    public override string FindUserLoginName(string nickName)
    {
    System.Web.Security.
    MembershipUser user = System.Web.Security.Membership.Providers["AspNetSqlMembershipProviderLiveSupport"].GetUser(nickName, false);
    if (user != null && user.IsApproved)
    {
    return user.UserName;
    }
    return null;
    }

    /// <summary>
    /// Gets the user info.
    /// </summary>
    /// <param name="loginName">Name of the login.</param>
    /// <param name="nickName">Name of the nick.</param>
    /// <param name="isAdmin">if set to <c>true</c> [is admin].</param>
    /// <returns>Override Boolean User Info Success.</returns>
    public override bool GetUserInfo(string loginName, ref string nickName, ref bool isAdmin)
    {
    System.Web.Security.
    MembershipUser user = System.Web.Security.Membership.Providers["AspNetSqlMembershipProviderLiveSupport"].GetUser(loginName, false);
    if (user != null && user.IsApproved)
    {
    nickName = user.UserName;
    isAdmin = System.Web.Security.
    Roles.Providers["AspNetSqlRoleProviderLiveSupport"].IsUserInRole(user.UserName, "Admin");
    return true;
    }
    return false;
    }

    /// <summary>
    /// Validates the user.
    /// </summary>
    /// <param name="username">The username.</param>
    /// <param name="password">The password.</param>
    /// <returns>Boolean Valid User.</returns>
    public override bool ValidateUser(string username, string password)
    {
    if (!System.Web.Security.Membership.Providers["AspNetSqlMembershipProviderLiveSupport"].ValidateUser(username, password))
    {
    return false;
    }
    System.Web.Security.
    FormsAuthentication.SetAuthCookie(username, false, HttpRuntime.AppDomainAppVirtualPath);
    return true;
    }
    }
    }


    Here is the config of the membership for the site as well as for livesupport in the primary website web.config:

    <membership defaultProvider="AspNetSqlMembershipProvider">

    <providers>

    <clear/>

    <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="TruSecurityConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/Tru.Site"/>

    <add name="AspNetSqlMembershipProviderLiveSupport" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="TruSecurityConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/Admin.Site"/>

    </providers>

    </membership>

    <profile defaultProvider="AspNetSqlProfileProvider">

    <providers>

    <clear/>

    <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="TruSecurityConnection" applicationName="/Tru.Site"/>

    <add name="AspNetSqlProfileProviderLiveSupport" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="TruSecurityConnection" applicationName="/Admin.Site"/>

    </providers>

    </profile>

    <roleManager defaultProvider="AspNetSqlRoleProvider" enabled="true">

    <providers>

    <clear/>

    <add connectionStringName="TruSecurityConnection" applicationName="/Tru.Site" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

    <add applicationName="/Tru.Site" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

    <add connectionStringName="TruSecurityConnection" applicationName="/Admin.Site" name="AspNetSqlRoleProviderLiveSupport" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

    <add applicationName="/Admin.Site" name="AspNetWindowsTokenRoleProviderLiveSupport" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

    </providers>

    </roleManager>





     
    Filed under:
  •  08-30-2009, 10:34 PM 55180 in reply to 55171

    Re: Login Form return OK, but lgoin failed!

    Please check the following line:
     
    isAdmin = System.Web.Security.Roles.Providers["AspNetSqlRoleProviderLiveSupport"].IsUserInRole(user.UserName, "Admin");
     
    Will it work if you just return true?
     
    isAdmin = true;
     
    Keep me posted

    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

  •  08-31-2009, 1:11 AM 55187 in reply to 55180

    Re: Login Form return OK, but lgoin failed!

    Hey Adam,
     
    I did as you suggested:
     

    isAdmin = true; // System.Web.Security.Roles.Providers["AspNetSqlRoleProviderLiveSupport"].IsUserInRole(user.UserName, "Admin");

    However the same problem persists...   another suggestion?
     
    Thanks,
     
    Michael
  •  08-31-2009, 1:51 AM 55191 in reply to 55187

    Re: Login Form return OK, but lgoin failed!

    Michael,
     
    What kind of problem?
     
    The operator cannot login the operator clients or the admin doesn't have permission to access the admin console?

    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

  •  08-31-2009, 3:30 AM 55197 in reply to 55191

    Re: Login Form return OK, but lgoin failed!

    The problem happens for both... "Login Form return OK, but login failed!"  it doesn't matter what user type I try to login with... the key is to use the alternate application because the website already has an application name... so there needs to be a way to pass the application name along with the connection attempt. 
     
    I think this is where the problem is:
     
    /// <summary>
    ///
    Gets the logon identity.
    ///
    </summary>
    /// <returns>Override of AppChatIdentity.
    </returns>
    public override AppChatIdentity GetLogonIdentity()
    {
    if (System.Web.Security.Membership.Provider.Name == "AspNetSqlMembershipProviderLiveSupport")
    {
    //this I think is where the problem is...
    System.Web.Security.MembershipUser user = System.Web.Security.Membership.GetUser();
    if (user != null && user.IsApproved)
    {
    return new AppChatIdentity(user.UserName, false, ToUserId(user.UserName), HttpContext.Current.Request.UserHostAddress);
    }
    }
    return null;
    }
    System.Web.Security.Membership.GetUser();   is trying to use the default provider when it should be attempt to use the AspNetSqlmembershipProviderLiveSupport.
     
     
  •  09-01-2009, 9:08 PM 55269 in reply to 55197

    Re: Login Form return OK, but lgoin failed!

    Hi,
     
    So did you fix that issue ?
     
    You should not use if (System.Web.Security.Membership.Provider.Name == "AspNetSqlMembershipProviderLiveSupport")
    Regards,
    Terry
  •  09-01-2009, 9:56 PM 55270 in reply to 55269

    Re: Login Form return OK, but lgoin failed!

    Hey,
     
    No, I've not yet fixed the issue, If I remove if (System.Web.Security.Membership.Provider.Name == "AspNetSqlMembershipProviderLiveSupport")
    then it trys to use the default provider to get the authentication, and I need it to use AspNetSqlMembershipProviderLiveSupport for the users that can use the LiveSupport tools.
     
    Still broken...
     
    Michael
  •  09-03-2009, 2:11 AM 55336 in reply to 55270

    Re: Login Form return OK, but lgoin failed!

    Hi

    while you use System.Web.Security.FormsAuthentication.SetAuthCookie(username, false, HttpRuntime.AppDomainAppVirtualPath);
    to save the authentication,

    In the GetLogonIdentity, you can write this thing :
     
    public override AppChatIdentity GetLogonIdentity()
    {
    if(!HttpContext.Current.User.Identity.IsAuthenticated)
        return null;
    return new AppChatIdentity(HttpContext.Current.User.Identity.Name, false, ToUserId(HttpContext.Current.User.Identity.Name), HttpContext.Current.Request.UserHostAddress);
    }
    Regards,
    Terry

    }
  •  09-03-2009, 4:47 PM 55364 in reply to 55336

    Re: Login Form return OK, but lgoin failed!

    Thanks Terry!  This fix corrects the problem.
  •  05-03-2011, 11:19 PM 67433 in reply to 55336

    Re: Login Form return OK, but lgoin failed!

    Hi Terry,
    Have this same issue, but in my case, the suggested code does not work.
    The problem is that when it comes into GetLogonIdentity(), the call to ...IsAuthenticated() returns false, even though just prior it called 
    ValidateUser()
    and did call 
    System.Web.Security.FormsAuthentication.SetAuthCookie(username, falseHttpRuntime.AppDomainAppVirtualPath); 
    I'm testing this on my development PC if that makes a difference.
     
    Thanks,
     
    Pat.
  •  05-04-2011, 1:28 PM 67445 in reply to 67433

    Re: Login Form return OK, but lgoin failed!

    Dear pjs75,
     
    Can you post your chat provider in this thread?
     
    Thank you  for asking
  •  05-04-2011, 4:43 PM 67447 in reply to 67445

    Re: Login Form return OK, but lgoin failed!

    Sure, here it is:
    ////////////////
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using CuteChat;
    using System.Data;
    using System.Data.Common;
    using System.Collections;
    using System.Data.SqlClient;
    using System.Data.Sql;


    /// <summary>
    /// Summary description for CCDVAChatProvider
    /// </summary>
    ///
    namespace ccdva
    {

        public class ASPNetChatProvider : ChatProvider
        {

            public ASPNetChatProvider()
            {
                //
                // TODO: Add constructor logic here
                //
            }

            static private string CuteChatConnectionStringConfigName = "ccdvaChat";


            public override string GetConnectionString()
            {
                return System.Configuration.ConfigurationManager.ConnectionStrings[CuteChatConnectionStringConfigName].ConnectionString;
            }

            public override AppChatIdentity GetLogonIdentity()
            {
                if (!HttpContext.Current.User.Identity.IsAuthenticated)
                    return null;

                return new AppChatIdentity(HttpContext.Current.User.Identity.Name, false, ToUserId(HttpContext.Current.User.Identity.Name), HttpContext.Current.Request.UserHostAddress);
            }

            public override string FindUserLoginName(string nickName)
            {
                System.Web.Security.MembershipUser user = System.Web.Security.Membership.GetUser(nickName, false);
                if (user != null && user.IsApproved)
                    return user.UserName;
                return null;
            }


            public override bool GetUserInfo(string loginName, ref string nickName, ref bool isAdmin)
            {
                System.Web.Security.MembershipUser user = System.Web.Security.Membership.GetUser(loginName, false);
                if (user != null && user.IsApproved)
                {
                    nickName = user.UserName;

                    // Default code was:
                    // isAdmin=Roles.IsUserInRole(user.UserName,"Administrators");

                    // If users are Staff, then consider them admins.
                    string[] roles = System.Web.Security.Roles.GetRolesForUser(user.UserName);
                    if (roles.Contains("Staff"))  isAdmin = true;

                    return true;
                }
                return false;
            }

            public override bool ValidateUser(string username, string password)
            {
                if (!System.Web.Security.Membership.ValidateUser(username, password))
                {
                    return false;
                }

                System.Web.Security.FormsAuthentication.SetAuthCookie(username, false, HttpRuntime.AppDomainAppVirtualPath);


                return true;
            }

        } // end class

    }
    ////////////////
     
  •  05-05-2011, 1:09 PM 67456 in reply to 67447

    Re: Login Form return OK, but lgoin failed!

    Dear
     
    Please add breakpoint in the following method, please check whether the higlighted line is called:
     
     public override AppChatIdentity GetLogonIdentity()
    {
    if (!HttpContext.Current.User.Identity.IsAuthenticated)
    return null;
    return new AppChatIdentity(HttpContext.Current.User.Identity.Name, false, ToUserId(HttpContext.Current.User.Identity.Name), HttpContext.Current.Request.UserHostAddress);
    }
    Thank you for asking
  •  05-05-2011, 5:08 PM 67459 in reply to 67456

    Re: Login Form return OK, but lgoin failed!

    Eric, I have done so. HttpContext.Current.User is null, so it returns null.
     
    I will be away for a few days, so won't respond until next monday.
     
    Pat.
  •  05-09-2011, 2:26 AM 67490 in reply to 67459

    Re: Login Form return OK, but lgoin failed!

    hi pjs75,
     
    Try change
     
     System.Web.Security.FormsAuthentication.SetAuthCookie(username, false, HttpRuntime.AppDomainAppVirtualPath);
     
    to
     
    System.Web.Security.FormsAuthentication.SetAuthCookie(username, false, "/");
     
     
    Regards,
     
    Ken
     
     
     
     
  •  06-02-2011, 9:24 PM 67791 in reply to 67490

    Re: Login Form return OK, but lgoin failed!

    Hi Ken,
    I eventually got around to working on this, and that worked, thanks.
     
    I have more questions, though I will post in new thread.
     
    Pat.
View as RSS news feed in XML