Hi,
you can create a new c# file name "DNNChatProvider.cs" in the App_Code folder and use the code below.
- using System;
- using System.IO;
- using System.Security;
- using System.Security.Principal;
- using System.Threading;
- using System.Web;
- using System.Web.Security;
- using System.Collections;
-
- using DotNetNuke.Common.Utilities;
- using DotNetNuke.Entities.Portals;
- using DotNetNuke.Security.Roles;
- using DotNetNuke.Services.Exceptions;
- using DotNetNuke.Services.Log.EventLog;
- using DotNetNuke.Services.Scheduling;
- using DotNetNuke.Services.Upgrade;
-
-
-
-
-
- public class DNNChatProvider : CuteChat.ChatProvider
- {
- protected DotNetNuke.Entities.Portals.PortalSettings CurrentPortal()
- {
-
- DotNetNuke.Entities.Portals.PortalSettings ps = default(DotNetNuke.Entities.Portals.PortalSettings);
-
- ps = PortalController.GetCurrentPortalSettings();
-
-
- if (ps == null)
- {
- throw (new System.Exception("PortalSettings Not Ready"));
-
- }
-
- return ps;
-
- }
- public DotNetNuke.Entities.Users.UserInfo GetLogonUser()
- {
-
-
- if (!HttpContext.Current.Request.IsAuthenticated)
- {
- return null;
-
- }
-
- string username = HttpContext.Current.User.Identity.Name;
-
- return DotNetNuke.Entities.Users.UserController.GetUserByName(CurrentPortal().PortalId, username);
-
- }
- public override string GetConnectionString()
- {
-
- return System.Configuration.ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString;
-
- }
- public override CuteChat.AppChatIdentity GetLogonIdentity()
- {
-
- DotNetNuke.Entities.Users.UserInfo user = GetLogonUser();
-
-
- if (user == null)
- {
- return null;
-
- }
-
- return new CuteChat.AppChatIdentity(user.Username, false, ToUserId(user.Username), HttpContext.Current.Request.UserHostAddress);
-
- }
- public override bool GetUserInfo(string loginName, ref string nickName, ref bool isAdmin)
- {
-
-
- try
- {
- DotNetNuke.Entities.Users.UserInfo user = DotNetNuke.Entities.Users.UserController.GetUserByName(CurrentPortal().PortalId, loginName);
-
-
- if (user == null)
- {
- return false;
-
- }
-
- nickName = user.Username;
-
- isAdmin = user.IsInRole("Administrators") | (user.Username == "admin");
-
- return true;
-
-
- }
- catch (System.Exception ex)
- {
- return false;
-
- }
-
- }
- public override string FindUserLoginName(string nickName)
- {
-
-
- try
- {
- int totalRecords = 0;
-
-
- foreach (DotNetNuke.Entities.Users.UserInfo user in DotNetNuke.Entities.Users.UserController.GetUsersByUserName(CurrentPortal().PortalId, false, nickName, 0, 100, ref totalRecords))
- {
-
- if (string.Equals(user.Username, nickName, StringComparison.OrdinalIgnoreCase))
- {
- return user.Username;
-
- }
-
- }
-
- return null;
-
-
- }
- catch (System.Exception ex)
- {
- return null;
-
- }
-
- }
- public override bool ValidateUser(string loginName, string password)
- {
-
-
- if (System.Web.Security.Membership.ValidateUser(loginName, password))
- {
- System.Web.Security.FormsAuthentication.SetAuthCookie(loginName, false);
-
- return true;
-
- }
- return false;
-
- }
-
- }
Regards,
ken