2 // System.Web.Security.MembershipUser
5 // Ben Maurer (bmaurer@users.sourceforge.net)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 namespace System.Web.Security {
33 public class MembershipUser {
34 protected MembershipUser ()
38 public MembershipUser (MembershipProvider provider, string name, string email,
39 string passwordQuestion, string comment, bool isApproved,
40 DateTime creationDate, DateTime lastLoginDate, DateTime lastActivityDate,
41 DateTime lastPasswordChangedDate)
43 this.provider = provider;
46 this.passwordQuestion = passwordQuestion;
47 this.comment = comment;
48 this.isApproved = isApproved;
49 this.creationDate = creationDate;
50 this.lastLoginDate = lastLoginDate;
51 this.lastActivityDate = lastActivityDate;
52 this.lastPasswordChangedDate = lastPasswordChangedDate;
55 public virtual bool ChangePassword (string oldPassword, string newPassword)
57 bool success = Provider.ChangePassword (Username, oldPassword, newPassword);
59 LastPasswordChangedDate = DateTime.Now;
64 public virtual bool ChangePasswordQuestionAndAnswer (string password, string newPasswordQuestion, string newPasswordAnswer)
66 bool success = Provider.ChangePasswordQuestionAndAnswer (Username, password, newPasswordQuestion, newPasswordAnswer);
68 passwordQuestion = newPasswordQuestion;
73 public virtual string GetPassword ()
75 return GetPassword (null);
78 public virtual string GetPassword (string answer)
80 return Provider.GetPassword (Username, answer);
83 public virtual string ResetPassword ()
85 return ResetPassword (null);
88 public virtual string ResetPassword (string answer)
90 string newPass = Provider.ResetPassword (Username, answer);
92 LastPasswordChangedDate = DateTime.Now;
97 public virtual string Comment {
98 get { return comment; }
99 set { comment = value; }
102 public virtual DateTime CreationDate {
103 get { return creationDate; }
104 set { creationDate = value; }
107 public virtual string Email {
108 get { return email; }
109 set { email = value; }
112 public virtual bool IsApproved {
113 get { return isApproved; }
114 set { isApproved = value; }
118 public bool IsOnline {
119 get { throw new NotImplementedException (); }
122 public virtual DateTime LastActivityDate {
123 get { return lastActivityDate; }
124 set { lastActivityDate = value; }
127 public virtual DateTime LastLoginDate {
128 get { return lastLoginDate; }
129 set { lastLoginDate = value; }
132 public virtual DateTime LastPasswordChangedDate {
133 get { return lastPasswordChangedDate; }
134 set { lastPasswordChangedDate = value; }
137 public virtual string PasswordQuestion {
138 get { return passwordQuestion; }
141 public virtual MembershipProvider Provider {
142 get { return provider; }
145 public virtual string Username {
149 MembershipProvider provider;
152 string passwordQuestion;
155 DateTime creationDate;
156 DateTime lastLoginDate;
157 DateTime lastActivityDate;
158 DateTime lastPasswordChangedDate;