DotNetNuke.Entities.Users 命名空间下的常用类总结
1.UserInfo类
该类可以获取所有在Users表里的用户信息
方法: IsInRole(string roleName) 判断用户是否在指定的roleName角色里面.
属性: IsSuperUser 判断用户是否是超级用户(管理员)
更详细资料请参考DNN API.
2.UserController类
该类可以创建新用户,删除用户,更新和随机生成新密码等等,太多了
详细:
View Code
Code public class UserController { // Fields private string _DisplayName; private int _PortalId; private static MembershipProvider memberProvider; // Methods static UserController(); public UserController(); private static void AddEventLog(int portalId, string username, int userId, string portalName, string Ip, UserLoginStatus loginStatus); public static bool ChangePassword(UserInfo user, string oldPassword, string newPassword); public static bool ChangePasswordQuestionAndAnswer(UserInfo user, string password, string passwordQuestion, string passwordAnswer); public static UserCreateStatus CreateUser(ref UserInfo objUser); public static void DeleteUnauthorizedUsers(int portalId); public static bool DeleteUser(ref UserInfo objUser, bool notify, bool deleteAdmin); public static void DeleteUsers(int portalId, bool notify, bool deleteAdmin); public static string GeneratePassword(); public static string GeneratePassword(int length); public static UserInfo GetCachedUser(int portalId, string username); public static UserInfo GetCurrentUserInfo(); - 常用 public static ArrayList GetOnlineUsers(int PortalId); public static string GetPassword(ref UserInfo user, string passwordAnswer); public static ArrayList GetUnAuthorizedUsers(int portalId); public static ArrayList GetUnAuthorizedUsers(int portalId, bool isHydrated); public UserInfo GetUser(int portalId, int userId); public static UserInfo GetUser(int portalId, int userId, bool isHydrated); public static UserInfo GetUserByName(int portalId, string username); public static UserInfo GetUserByName(int portalId, string username, bool isHydrated); public static int GetUserCountByPortal(int portalId); public static string GetUserCreateStatus(UserCreateStatus UserRegistrationStatus); public static void GetUserMembership(ref UserInfo objUser); public static ArrayList GetUsers(int portalId); public static ArrayList GetUsers(int portalId, bool isHydrated); public static ArrayList GetUsers(int portalId, int pageIndex, int pageSize, ref int totalRecords); public static ArrayList GetUsers(int portalId, bool isHydrated, int pageIndex, int pageSize, ref int totalRecords); public static ArrayList GetUsersByEmail(int portalId, string emailToMatch, int pageIndex, int pageSize, ref int totalRecords); public static ArrayList GetUsersByEmail(int portalId, bool isHydrated, string emailToMatch, int pageIndex, int pageSize, ref int totalRecords); public static ArrayList GetUsersByProfileProperty(int portalId, string propertyName, string propertyValue, int pageIndex, int pageSize, ref int totalRecords); public static ArrayList GetUsersByProfileProperty(int portalId, bool isHydrated, string propertyName, string propertyValue, int pageIndex, int pageSize, ref int totalRecords); public static ArrayList GetUsersByUserName(int portalId, string userNameToMatch, int pageIndex, int pageSize, ref int totalRecords); public static ArrayList GetUsersByUserName(int portalId, bool isHydrated, string userNameToMatch, int pageIndex, int pageSize, ref int totalRecords); public static Hashtable GetUserSettings(int portalId); public static string ResetPassword(UserInfo user, string passwordAnswer); public static void SetAuthCookie(string username, bool CreatePersistentCookie); public static string SettingsKey(int portalId); public static bool UnLockUser(UserInfo user); public void UpdateDisplayNames(); public static void UpdateUser(int portalId, UserInfo objUser); public static void UserLogin(int portalId, UserInfo user, string PortalName, string IP, bool CreatePersistentCookie); public static UserInfo UserLogin(int portalId, string Username, string Password, string VerificationCode, string PortalName, string IP, ref UserLoginStatus loginStatus, bool CreatePersistentCookie); public static bool ValidatePassword(string password); public static UserValidStatus ValidateUser(UserInfo objUser, int portalId, bool ignoreExpiring); public static UserInfo ValidateUser(int portalId, string Username, string Password, string VerificationCode, string PortalName, string IP, ref UserLoginStatus loginStatus); public static UserInfo ValidateUser(int portalId, string Username, string Password, string authType, string VerificationCode, string PortalName, string IP, ref UserLoginStatus loginStatus); // Properties public string DisplayFormat { get; set; } public int PortalId { get; set; } }
3、其他类
View Code
Code public class UserOnlineController public class AnonymousUserInfo : BaseUserInfo public class UserMembership