2 // System.Web.Security.Membership
5 // Ben Maurer (bmaurer@users.sourceforge.net)
6 // Lluis Sanchez Gual (lluis@novell.com)
9 // (C) 2005 Novell, inc.
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System.Collections;
35 using System.Collections.Specialized;
38 namespace System.Web.Security
40 public abstract class Membership
46 public static MembershipUser CreateUser (string username, string password)
48 return CreateUser (username, password, null);
51 public static MembershipUser CreateUser (string username, string password, string email)
53 MembershipCreateStatus status;
54 MembershipUser usr = CreateUser (username, password, email, null, null, true, out status);
56 throw new MembershipCreateUserException (status);
61 public static MembershipUser CreateUser (string username, string password, string email, string pwdQuestion, string pwdAnswer, bool isApproved, out MembershipCreateStatus status)
63 return Provider.CreateUser (username, password, email, pwdQuestion, pwdAnswer, isApproved, null, out status);
66 public static MembershipUser CreateUser (string username, string password, string email, string pwdQuestion, string pwdAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
68 return Provider.CreateUser (username, password, email, pwdQuestion, pwdAnswer, isApproved, providerUserKey, out status);
71 public static bool DeleteUser (string username)
73 return Provider.DeleteUser (username, true);
76 public static bool DeleteUser (string username, bool deleteAllRelatedData)
78 return Provider.DeleteUser (username, deleteAllRelatedData);
82 public static string GeneratePassword (int length, int numberOfNonAlphanumericCharacters)
84 throw new NotImplementedException ();
87 public static MembershipUserCollection GetAllUsers ()
90 return GetAllUsers (1, int.MaxValue, out total);
93 public static MembershipUserCollection GetAllUsers (int pageIndex, int pageSize, out int totalRecords)
95 return Provider.GetAllUsers (pageIndex, pageSize, out totalRecords);
98 public static int GetNumberOfUsersOnline ()
100 return Provider.GetNumberOfUsersOnline ();
103 public static MembershipUser GetUser ()
105 return GetUser (HttpContext.Current.User.Identity.Name, true);
108 public static MembershipUser GetUser (bool userIsOnline)
110 return GetUser (HttpContext.Current.User.Identity.Name, userIsOnline);
113 public static MembershipUser GetUser (string username)
115 return GetUser (username, false);
118 public static MembershipUser GetUser (string username, bool userIsOnline)
120 return Provider.GetUser (username, userIsOnline);
123 public static MembershipUser GetUser (object providerUserKey)
125 return GetUser (providerUserKey, false);
128 public static MembershipUser GetUser (object providerUserKey, bool userIsOnline)
130 return Provider.GetUser (providerUserKey, userIsOnline);
133 public static string GetUserNameByEmail (string email)
135 return Provider.GetUserNameByEmail (email);
138 public static void UpdateUser (MembershipUser user)
140 Provider.UpdateUser (user);
143 public static bool ValidateUser (string username, string password)
145 return Provider.ValidateUser (username, password);
148 public static MembershipUserCollection FindUsersByEmail (string emailToMatch)
151 return Provider.FindUsersByEmail (emailToMatch, 0, int.MaxValue, out totalRecords);
154 public static MembershipUserCollection FindUsersByEmail (string emailToMatch, int pageIndex, int pageSize, out int totalRecords)
156 return Provider.FindUsersByEmail (emailToMatch, pageIndex, pageSize, out totalRecords);
159 public static MembershipUserCollection FindUsersByName (string nameToMatch)
162 return Provider.FindUsersByName (nameToMatch, 0, int.MaxValue, out totalRecords);
165 public static MembershipUserCollection FindUsersByName (string nameToMatch, int pageIndex, int pageSize, out int totalRecords)
167 return Provider.FindUsersByName (nameToMatch, pageIndex, pageSize, out totalRecords);
172 public static string ApplicationName {
173 get { return Provider.ApplicationName; }
174 set { Provider.ApplicationName = value; }
177 public static bool EnablePasswordReset {
178 get { return Provider.EnablePasswordReset; }
181 public static bool EnablePasswordRetrieval {
182 get { return Provider.EnablePasswordRetrieval; }
185 public static bool RequiresQuestionAndAnswer {
186 get { return Provider.RequiresQuestionAndAnswer; }
189 public static int MaxInvalidPasswordAttempts {
190 get { return Provider.MaxInvalidPasswordAttempts; }
193 public static int MinRequiredNonAlphanumericCharacters {
194 get { return Provider.MinRequiredNonAlphanumericCharacters; }
197 public static int MinRequiredPasswordLength {
198 get { return Provider.MinRequiredPasswordLength; }
201 public static int PasswordAttemptWindow {
202 get { return Provider.PasswordAttemptWindow; }
205 public static string PasswordStrengthRegularExpression {
206 get { return Provider.PasswordStrengthRegularExpression; }
210 public static MembershipProvider Provider {
211 get { throw new NotImplementedException (); }
215 public static MembershipProviderCollection Providers {
216 get { throw new NotImplementedException (); }
220 public static int UserIsOnlineTimeWindow {
221 get { throw new NotImplementedException (); }
224 public event MembershipValidatePasswordEventHandler ValidatingPassword {
225 add { Provider.ValidatingPassword += value; }
226 remove { Provider.ValidatingPassword -= value; }