Re: cutechat integration horror

  •  01-14-2005, 10:09 AM

    Re: cutechat integration horror

    janus,

    Did you miss the following step?




    Create a class which implements the IUserIdentityAdapter interface and name it SqlServerUserIdentityAdapter.

    public class SqlServerUserIdentityAdapter : IUserIdentityAdapter 
    {
    }
    To provide a complete implementation, we will need to provide overrides for the two methos of the SqlServerUserIdentityAdapter class as followings:

    1. The implementation of the GetCurrentUserUniqueName method

    Description:
    Retrieves the user name of the current user.

    public string GetCurrentUserUniqueName(HttpContext context) { 
        IIdentity iden=context.User.Identity; 
        if(iden==null||!iden.IsAuthenticated) 
           return null; 
        if(iden.Name==null||iden.Name.Length==0) 
           return null; 
        return iden.Name; 
    }

    The implementation of the IsAdministrators method

    Description:
    Check the current user is an administrator or not..

    public bool IsAdministrators(string useruniquename) { 
        using(IDataAccess da=ChatConfig.CreateDataAccess()) { 
           int userid=da.GetUserInternalId(useruniquename); 
           if(userid==0)
               return false; 
           DataRow row=da.SelectUser(userid); 
           if(row==null)
               return false; 
           return Convert.ToBoolean(row["isadmin"]); 
        } 
    }




    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

View Complete Thread