Re: Login Form return OK, but lgoin failed!

  •  08-29-2009, 4:34 PM

    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:
View Complete Thread
Powered by Community Server (Commercial Edition), by Telligent Systems