DNN如何取得当前用户常用信息
在DNN模块开发过程中,常常需要得到当前登录用户的信息.方法如下:
添加using:
using DotNetNuke.Entities.Users;
代码:
用户 AffiliateID : ((UserInfo)UserController.GetCurrentUserInfo()).AffiliateID.ToString();
用户 Cacheability : ((UserInfo)UserController.GetCurrentUserInfo()).Cacheability.ToString();
用户 DisplayName : ((UserInfo)UserController.GetCurrentUserInfo()).DisplayName.ToString();
用户 Email : ((UserInfo)UserController.GetCurrentUserInfo()).Email.ToString();
用户 FirstName : ((UserInfo)UserController.GetCurrentUserInfo()).FirstName.ToString();
用户 FullName : ((UserInfo)UserController.GetCurrentUserInfo()).FullName.ToString();//这个就等于 FirstName + LastName
用户 IsSuperUser : ((UserInfo)UserController.GetCurrentUserInfo()).IsSuperUser.ToString();//判断当前用户是否是超级用户
用户 LastName : ((UserInfo)UserController.GetCurrentUserInfo()).LastName.ToString();
用户 Membership : ((UserInfo)UserController.GetCurrentUserInfo()).Membership.ToString();
用户 PortalID : ((UserInfo)UserController.GetCurrentUserInfo()).PortalID.ToString();
用户 Profile : ((UserInfo)UserController.GetCurrentUserInfo()).Profile.ToString();
用户 Roles : ((UserInfo)UserController.GetCurrentUserInfo()).Roles.ToString();
用户 UserID : ((UserInfo)UserController.GetCurrentUserInfo()).UserID.ToString();
用户 Username : ((UserInfo)UserController.GetCurrentUserInfo()).Username.ToString();
注:红色为常用属性,希望对大家的开发能有所帮助.
