Author: kostat
Date: 2006-08-28 08:18:44 -0400 (Mon, 28 Aug 2006)
New Revision: 64470
Modified:
trunk/mcs/class/System.Web/System.Web.Security/ChangeLog
trunk/mcs/class/System.Web/System.Web.Security/SqlMembershipProvider.cs
Log:
* SqlMembershipProvider.cs: ensure GetUser() returns null if it cannot
retrieve user information
Modified: trunk/mcs/class/System.Web/System.Web.Security/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Security/ChangeLog 2006-08-28
12:10:02 UTC (rev 64469)
+++ trunk/mcs/class/System.Web/System.Web.Security/ChangeLog 2006-08-28
12:18:44 UTC (rev 64470)
@@ -1,5 +1,10 @@
2006-08-28 Konstantin Triger <[EMAIL PROTECTED]>
+ * SqlMembershipProvider.cs: ensure GetUser() returns null if it cannot
+ retrieve user information.
+
+2006-08-28 Konstantin Triger <[EMAIL PROTECTED]>
+
* SqlRoleProvider.cs, SqlMembershipProvider.cs:
"use SqlClientFactory in case the ProviderName is not specified.
Modified:
trunk/mcs/class/System.Web/System.Web.Security/SqlMembershipProvider.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Security/SqlMembershipProvider.cs
2006-08-28 12:10:02 UTC (rev 64469)
+++ trunk/mcs/class/System.Web/System.Web.Security/SqlMembershipProvider.cs
2006-08-28 12:18:44 UTC (rev 64470)
@@ -917,35 +917,39 @@
{
DbDataReader reader = null;
try {
- reader = query.ExecuteReader ();
- if (!reader.Read ())
- return null;
+ using (DbConnection connection =
CreateConnection ()) {
- MembershipUser user = GetUserFromReader
(reader);
+ query.Connection = connection;
+ reader = query.ExecuteReader ();
+ if (!reader.Read ())
+ return null;
- if (user != null && userIsOnline) {
+ MembershipUser user = GetUserFromReader
(reader);
- string commandText;
- DbCommand command;
+ if (user != null && userIsOnline) {
- commandText = @"
+ string commandText;
+ DbCommand command;
+
+ commandText = @"
UPDATE dbo.aspnet_Users u, dbo.aspnet_Application a
SET u.LastActivityDate = GETDATE()
WHERE u.ApplicationId = a.ApplicationId
AND u.UserName = @UserName
AND a.LoweredApplicationName = LOWER(@ApplicationName)";
- command = factory.CreateCommand ();
- command.CommandText = commandText;
- command.Connection = query.Connection;
- command.CommandType = CommandType.Text;
- AddParameter (command, "UserName",
user.UserName);
- AddParameter (command,
"ApplicationName", ApplicationName);
+ command = factory.CreateCommand
();
+ command.CommandText =
commandText;
+ command.Connection =
query.Connection;
+ command.CommandType =
CommandType.Text;
+ AddParameter (command,
"UserName", user.UserName);
+ AddParameter (command,
"ApplicationName", ApplicationName);
- command.ExecuteNonQuery();
- }
+ command.ExecuteNonQuery ();
+ }
- return user;
+ return user;
+ }
}
catch {
return null; /* should we let the exception
through? */
@@ -964,9 +968,7 @@
string commandText;
DbCommand command;
- using (DbConnection connection = CreateConnection ()) {
-
- commandText = @"
+ commandText = @"
SELECT u.UserName, m.UserId, m.Email, m.PasswordQuestion, m.Comment,
m.IsApproved,
m.IsLockedOut, m.CreateDate, m.LastLoginDate, u.LastActivityDate,
m.LastPasswordChangedDate, m.LastLockoutDate
@@ -977,17 +979,15 @@
AND u.UserName = @UserName
AND a.LoweredApplicationName = LOWER(@ApplicationName)";
- command = factory.CreateCommand ();
- command.CommandText = commandText;
- command.Connection = connection;
- command.CommandType = CommandType.Text;
- AddParameter (command, "UserName", username);
- AddParameter (command, "ApplicationName",
ApplicationName);
+ command = factory.CreateCommand ();
+ command.CommandText = commandText;
+ command.CommandType = CommandType.Text;
+ AddParameter (command, "UserName", username);
+ AddParameter (command, "ApplicationName",
ApplicationName);
- MembershipUser u = BuildMembershipUser
(command, userIsOnline);
+ MembershipUser u = BuildMembershipUser (command,
userIsOnline);
- return u;
- }
+ return u;
}
[MonoTODO]
@@ -996,9 +996,7 @@
string commandText;
DbCommand command;
- using (DbConnection connection = CreateConnection ()) {
-
- commandText = @"
+ commandText = @"
SELECT u.UserName, m.UserId, m.Email, m.PasswordQuestion, m.Comment,
m.IsApproved,
m.IsLockedOut, m.CreateDate, m.LastLoginDate, u.LastActivityDate,
m.LastPasswordChangedDate, m.LastLockoutDate
@@ -1009,17 +1007,15 @@
AND u.UserId = @UserKey
AND a.LoweredApplicationName = LOWER(@ApplicationName)";
- command = factory.CreateCommand ();
- command.CommandText = commandText;
- command.Connection = connection;
- command.CommandType = CommandType.Text;
- AddParameter (command, "UserKey",
providerUserKey.ToString ());
- AddParameter (command, "ApplicationName",
ApplicationName);
+ command = factory.CreateCommand ();
+ command.CommandText = commandText;
+ command.CommandType = CommandType.Text;
+ AddParameter (command, "UserKey",
providerUserKey.ToString ());
+ AddParameter (command, "ApplicationName",
ApplicationName);
- MembershipUser u = BuildMembershipUser
(command, userIsOnline);
+ MembershipUser u = BuildMembershipUser (command,
userIsOnline);
- return u;
- }
+ return u;
}
[MonoTODO]
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches