Asp database site

Last post 09-03-2004, 12:10 PM by cutechat. 3 replies.
Sort Posts: Previous Next
  •  09-03-2004, 8:34 AM 1702

    Asp database site

    Our site uses an access database membership system.  Are there ways to use the existing usernames and passwords in cutechat?
  •  09-03-2004, 9:36 AM 1707 in reply to 1702

    Re: Asp database site

     
    Yes , the CuteChat support any user-data-model .
    (SqlServer,Access..Databases.. Passport,SharePoint,ActiveDirectory...)
     
    Please open the :
    C:\Program Files\CuteSoft\CuteChat\Toolkit\Solution
     
    There is some sample about intergate the user-model for existing website .
     
    If you what to do that too , you must create a class that inherits CuteChat.SqlServer.SqlDataProvider
     
    for example :
     
    public class MyDataProvider : CuteChat.SqlServer.SqlDataProvider
    {
        //this connectionsting is for SqlServer2000/MSDE2000
        public YourDataProvider (string connectionstring):base(connectionstring)
        {
        }
        public override UserInfoData GetUserInfo(string useruniquename)
        {
            ...connect the access database
            ...get the username for the useruniquename here .. the useruniquename is from ListUserUniqueName()
            return new UserInfoData(useruniquename,username,isadmin);
        }
        public override string[] ListUserUniqueName()
        {
            ...connect the access database
            ...select all user primarykey (id,loginname,email or any unique thing) and return .
        }
        public override bool IsUserNickNameExists(string nickname)
        {
            ...connect the access database
            ...find whether the nickname is registered.
        }
    }
     
    If you website use custom authentication way (for example, you use the cookie) ,
     please create a class that implement the CuteChat.IUserIdentityAdapter
     
    for example:
     
    public class MyUserAdapter : IUserIdentityAdapter
    {
        public string GetCurrentUserUniqueName(HttpContext context)
        {
            HttpCookie cookie=context.Request.Cookies["MyUserInfo"];
            if(cookie==null)return null;
            string username=cookie["UserName"];
            if(username==null||username=="")return null;
            return null;
        }
        public bool IsAdministrators(string useruniquename)
        {
             ...connect to access database , find whether the user is site administrator
        }
    }
     
    When these are done , you must configurate it in web.config :
     
    <cuteChat ... >
        <providers defaultProvider="MyProvider">
            <provider name="MyProvider" sqlDataProviderType="MyNamespace.MyDataProvider,MyDllName"
                    userIdentityAdapterType="MyNamespace.MyUserAdapter,MyDllName" />
        </providers>
    </cuteChat>
     
    Reards , Terry .
  •  09-03-2004, 10:37 AM 1709 in reply to 1707

    Re: Asp database site

    Thanks for your extensive help!  I will struggle with that so will be back to ask some more I expect :)
  •  09-03-2004, 12:10 PM 1710 in reply to 1709

    Re: Asp database site

    :) Glad that I could help .

     
    I just make a mistake on the sample code :
     
    public string GetCurrentUserUniqueName(HttpContext context)
    {
        HttpCookie cookie=context.Request.Cookies["MyUserInfo"];"];//get the custom authentication information
        if(cookie==null)return null;//if the user is anonymous
        string username=cookie["UserName"];//get the custom authentication information
        if(username==null||username=="")return null;//if the user is anonymous
        return username;//return the useruniquename or the signed user .
    }
View as RSS news feed in XML