X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FMainsoft.Web%2FMainsoft.Web.Security%2FDerbyRoleProvider.cs;h=cdce377b281f9f2cba730b786d5e6a9ae36eb961;hb=5ad1099341581dee94f77b32db728918e90fa64f;hp=c2ae24eff2f856d3fe152eb885f9baca3da7faa8;hpb=53e266903ec6b2d822cf5b0c566f6374df5307a4;p=mono.git diff --git a/mcs/class/Mainsoft.Web/Mainsoft.Web.Security/DerbyRoleProvider.cs b/mcs/class/Mainsoft.Web/Mainsoft.Web.Security/DerbyRoleProvider.cs index c2ae24eff2f..cdce377b281 100644 --- a/mcs/class/Mainsoft.Web/Mainsoft.Web.Security/DerbyRoleProvider.cs +++ b/mcs/class/Mainsoft.Web/Mainsoft.Web.Security/DerbyRoleProvider.cs @@ -42,14 +42,26 @@ using System.Web.Security; namespace Mainsoft.Web.Security { - + /// + /// This class supports the Framework infrastructure and is not intended to be used directly from your code. + /// Manages storage of role membership information for an ASP.NET application in a Derby database. + /// public class DerbyRoleProvider : RoleProvider { ConnectionStringSettings connectionString; string applicationName; + bool schemaChecked = false; + DerbyUnloadManager.DerbyShutDownPolicy shutDownPolicy = DerbyUnloadManager.DerbyShutDownPolicy.Default; DbConnection CreateConnection () { + if (!schemaChecked) { + DerbyDBSchema.CheckSchema (connectionString.ConnectionString); + schemaChecked = true; + + DerbyUnloadManager.RegisterUnloadHandler (connectionString.ConnectionString, shutDownPolicy); + } + OleDbConnection connection = new OleDbConnection (connectionString.ConnectionString); connection.Open (); return connection; @@ -126,7 +138,7 @@ namespace Mainsoft.Web.Security if (returnValue == 0) return true; if (returnValue == 2) - return false; //role does not exists + return false; //role does not exist else if (returnValue == 3 && throwOnPopulatedRole) throw new ProviderException (rolename + " is not empty"); else @@ -151,7 +163,7 @@ namespace Mainsoft.Web.Security int returnValue = DerbyRolesHelper.UsersInRoles_FindUsersInRole (connection, applicationName, roleName, usernameToMatch, out reader); if (returnValue == 2) - throw new ProviderException ("roleName was not found in the database"); + throw new ProviderException ("The role '" + roleName + "' was not found."); using (reader) { if (reader == null) @@ -222,7 +234,7 @@ namespace Mainsoft.Web.Security int returnValue = DerbyRolesHelper.UsersInRoles_GetUsersInRoles (connection, applicationName, rolename, out reader); if (returnValue == 2) - throw new ProviderException ("rolename was not found in the database"); + throw new ProviderException ("The role '" + rolename + "' was not found."); using (reader) { if (reader == null) @@ -265,7 +277,9 @@ namespace Mainsoft.Web.Security if (connectionString == null) throw new ProviderException (String.Format("The connection name '{0}' was not found in the applications configuration or the connection string is empty.", connectionStringName)); - DerbyDBSchema.InitializeSchema (connectionString.ConnectionString); + string shutdown = config ["shutdown"]; + if (!String.IsNullOrEmpty (shutdown)) + shutDownPolicy = (DerbyUnloadManager.DerbyShutDownPolicy) Enum.Parse (typeof (DerbyUnloadManager.DerbyShutDownPolicy), shutdown, true); } public override bool IsUserInRole (string username, string rolename)