2 // System.Web.Security.Membership
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 using System.Collections;
33 using System.Collections.Specialized;
36 namespace System.Web.Security {
37 public sealed class Membership {
39 private Membership () {}
41 public static MembershipUser CreateUser (string username, string password)
43 return CreateUser (username, password, null);
46 public static MembershipUser CreateUser (string username, string password, string email)
48 MembershipCreateStatus status;
49 MembershipUser usr = CreateUser (username, password, email, null, null, true, out status);
51 throw new MembershipCreateUserException (status);
56 public static MembershipUser CreateUser (string username, string password, string email, string pwdQuestion, string pwdAnswer, bool isApproved, out MembershipCreateStatus status)
58 return Provider.CreateUser (username, password, email, pwdQuestion, pwdAnswer, isApproved, out status);
61 public static bool DeleteUser (string username)
63 return Provider.DeleteUser (username, true);
66 public static bool DeleteUser (string username, bool deleteAllRelatedData)
68 return Provider.DeleteUser (username, deleteAllRelatedData);
72 public static string GeneratePassword (int length)
74 throw new NotImplementedException ();
77 public static MembershipUserCollection GetAllUsers ()
80 return GetAllUsers (1, int.MaxValue, out total);
83 public static MembershipUserCollection GetAllUsers (int pageIndex, int pageSize, out int totalRecords)
85 return Provider.GetAllUsers (pageIndex, pageSize, out totalRecords);
88 public static int GetNumberOfUsersOnline ()
90 return Provider.GetNumberOfUsersOnline ();
93 public static MembershipUser GetUser ()
95 return GetUser (HttpContext.Current.User.Identity.Name, true);
98 public static MembershipUser GetUser (bool userIsOnline)
100 return GetUser (HttpContext.Current.User.Identity.Name, userIsOnline);
103 public static MembershipUser GetUser (string username)
105 return GetUser (username, false);
108 public static MembershipUser GetUser (string username, bool userIsOnline)
110 return Provider.GetUser (username, userIsOnline);
113 public static string GetUserNameByEmail (string email)
115 return Provider.GetUserNameByEmail (email);
118 public static void UpdateUser (MembershipUser user)
120 Provider.UpdateUser (user);
123 public static bool ValidateUser (string username, string password)
125 return Provider.ValidateUser (username, password);
128 public static string ApplicationName {
129 get { return Provider.ApplicationName; }
130 set { Provider.ApplicationName = value; }
133 public static bool EnablePasswordReset {
134 get { return Provider.EnablePasswordReset; }
137 public static bool EnablePasswordRetrieval {
138 get { return Provider.EnablePasswordRetrieval; }
141 public static bool RequiresQuestionAndAnswer {
142 get { return Provider.RequiresQuestionAndAnswer; }
146 public static MembershipProvider Provider {
147 get { throw new NotImplementedException (); }
151 public static MembershipProviderCollection Providers {
152 get { throw new NotImplementedException (); }
156 public static int UserIsOnlineTimeWindow {
157 get { throw new NotImplementedException (); }