编写自身的 oluUserInfoProvider 。示例代码如下(采用Forms验证):
public class oluUserInfoProvider_Demo : oluUserInfoProvider
{
public override void AuthenticationSignout()
{
FormsAuthentication.SignOut();
}
public override oluUserInfo CreateMember(string IdentityName)
{
string nick=string.Format("会员:{0}",IdentityName);//应该去获取真正昵称
oluUserInfo ui = new oluUserInfo(IdentityName, nick, false, null);
return ui;
}
public override oluUserInfo CreateGuest()
{
oluUserInfo ui = new oluUserInfo("Guest", "路人甲", true, null);
return ui;
}
}
如果默认的oluUserInfo实体类不能满足要求,可以自行扩展;若不打算扩展,也可以将真正的会员信息实体类存到oluUserInfo的InnerUserData属性中。
扩展oluUserInfo实体类的代码示例:
public class oluUserInfoExtend : oluUserInfo
{
private string m_UserHostAddress = string.Empty;
private string m_BrowserType = string.Empty;
private string m_Platform = string.Empty;
public oluUserInfoExtend(string userName, string nickName, bool anonymous, object userData)
: base(userName,nickName,anonymous,userData)
{
m_UserHostAddress = HttpContext.Current.Request.UserHostAddress;
m_BrowserType = HttpContext.Current.Request.Browser.Type;
m_Platform = HttpContext.Current.Request.Browser.Platform;
}
public string UserHostAddress
{
get { return m_UserHostAddress; }
}
public string BrowserType
{
get { return m_BrowserType; }
}
public string Platform
{
get { return m_Platform; }
}
}