日期:2010-05-18 浏览次数:20552 次
[Serializable]
public class MembershipUser{
public virtual bool ChangePassword(string oldPassword,string newPassword);
public virtual string GetPassword(string passwordAnswer);
public virtual string ResetPassword(string passwordAnswer);
public virtual bool UnlockUser();
//其它成员
}
public static class Membership{
public static string ApplicationName{get;set;}
public static MembershipUser CreateUser(string username, string password);
public static MembershipUser CreateUser(string username,
string password, string email, string passwordQuestion,
string passwordAnswer, bool isApproved, out MembershipCreateStatus status);
public static bool DeleteUser(string username,bool deleteAllRelatedData);
public static MembershipUser GetUser(string username);
public static void UpdateUser(MembershipUser user);
public static bool ValidateUser(string username,string password);
public static bool EnablePasswordReset{get;}
public static bool EnablePasswordRetrieval{get;}
//其它成员
}
Membership.ApplicationName = "MyApp";
Membership.CreateUser("MyUser","MyPassword",...);
public static class Roles{
public static string ApplicationName{get;set;}
public static void CreateRole(string roleName);
public static bool DeleteRole(string roleName, bool throwOnPopulatedRole);
public static void AddUserToRole(string username, string roleName);
public static void RemoveUserFromRole(string username, string roleName);
public static string[] GetAllRoles();
public static string[] GetRolesForUser(string username);
public static string[] GetUsersInRole(string roleName);
public static bool IsUserInRole(string username, string roleName);
//其它成员
}
Roles.ApplicationName = "MyApp";
Roles.CreateRole("Manager");