Copied remotely
[mono.git] / mcs / class / System.Web / System.Web.Security / Membership.cs
1 //
2 // System.Web.Security.Membership
3 //
4 // Authors:
5 //      Ben Maurer (bmaurer@users.sourceforge.net)
6 //
7 // (C) 2003 Ben Maurer
8 //
9
10 //
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:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
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.
29 //
30
31 #if NET_2_0
32 using System.Collections;
33 using System.Collections.Specialized;
34 using System.Text;
35
36 namespace System.Web.Security {
37         public sealed class Membership {
38                 
39                 private Membership () {}
40                 
41                 public static MembershipUser CreateUser (string username, string password)
42                 {
43                         return CreateUser (username, password, null);
44                 }
45                 
46                 public static MembershipUser CreateUser (string username, string password, string email)
47                 {
48                         MembershipCreateStatus status;
49                         MembershipUser usr = CreateUser (username, password, email, null, null, true, out status);
50                         if (usr == null)
51                                 throw new MembershipCreateUserException (status);
52                         
53                         return usr;
54                 }
55                 
56                 public static MembershipUser CreateUser (string username, string password, string email, string pwdQuestion, string pwdAnswer, bool isApproved, out MembershipCreateStatus status)
57                 {
58                         return Provider.CreateUser (username, password, email, pwdQuestion, pwdAnswer, isApproved, out status);
59                 }
60                 
61                 public static bool DeleteUser (string username)
62                 {
63                         return Provider.DeleteUser (username, true);
64                 }
65                 
66                 public static bool DeleteUser (string username, bool deleteAllRelatedData)
67                 {
68                         return Provider.DeleteUser (username, deleteAllRelatedData);
69                 }
70                 
71                 [MonoTODO]
72                 public static string GeneratePassword (int length)
73                 {
74                         throw new NotImplementedException ();
75                 }
76                 
77                 public static MembershipUserCollection GetAllUsers ()
78                 {
79                         int total;
80                         return GetAllUsers (1, int.MaxValue, out total);
81                 }
82                 
83                 public static MembershipUserCollection GetAllUsers (int pageIndex, int pageSize, out int totalRecords)
84                 {
85                         return Provider.GetAllUsers (pageIndex, pageSize, out totalRecords);
86                 }
87                 
88                 public static int GetNumberOfUsersOnline ()
89                 {
90                         return Provider.GetNumberOfUsersOnline ();
91                 }
92                 
93                 public static MembershipUser GetUser ()
94                 {
95                         return GetUser (HttpContext.Current.User.Identity.Name, true);
96                 }
97                 
98                 public static MembershipUser GetUser (bool userIsOnline)
99                 {
100                         return GetUser (HttpContext.Current.User.Identity.Name, userIsOnline);
101                 }
102                 
103                 public static MembershipUser GetUser (string username)
104                 {
105                         return GetUser (username, false);
106                 }
107                 
108                 public static MembershipUser GetUser (string username, bool userIsOnline)
109                 {
110                         return Provider.GetUser (username, userIsOnline);
111                 }
112                 
113                 public static string GetUserNameByEmail (string email)
114                 {
115                         return Provider.GetUserNameByEmail (email);
116                 }
117                 
118                 public static void UpdateUser (MembershipUser user)
119                 {
120                         Provider.UpdateUser (user);
121                 }
122                 
123                 public static bool ValidateUser (string username, string password)
124                 {
125                         return Provider.ValidateUser (username, password);
126                 }
127                 
128                 public static string ApplicationName {
129                         get { return Provider.ApplicationName; }
130                         set { Provider.ApplicationName = value; }
131                 }
132                 
133                 public static bool EnablePasswordReset {
134                         get { return Provider.EnablePasswordReset; }
135                 }
136                 
137                 public static bool EnablePasswordRetrieval {
138                         get { return Provider.EnablePasswordRetrieval; }
139                 }
140                 
141                 public static bool RequiresQuestionAndAnswer {
142                         get { return Provider.RequiresQuestionAndAnswer; }
143                 }
144                 
145                 [MonoTODO]
146                 public static MembershipProvider Provider {
147                         get { throw new NotImplementedException (); }
148                 }
149                 
150                 [MonoTODO]
151                 public static MembershipProviderCollection Providers {
152                         get { throw new NotImplementedException (); }
153                 }
154                 
155                 [MonoTODO]
156                 public static int UserIsOnlineTimeWindow {
157                         get { throw new NotImplementedException (); }
158                 }
159         }
160 }
161 #endif
162