\r
namespace Mainsoft.Web.Security\r
{\r
-\r
+ /// <summary>\r
+ /// <para>This class supports the Framework infrastructure and is not intended to be used directly from your code.</para>\r
+ /// <para>Manages storage of role membership information for an ASP.NET application in a Derby database.</para>\r
+ /// </summary>\r
public class DerbyRoleProvider : RoleProvider\r
{\r
ConnectionStringSettings connectionString;\r
string applicationName;\r
+ bool schemaChecked = false;\r
+ DerbyUnloadManager.DerbyShutDownPolicy shutDownPolicy = DerbyUnloadManager.DerbyShutDownPolicy.Default;\r
\r
DbConnection CreateConnection ()\r
{\r
+ if (!schemaChecked) {\r
+ DerbyDBSchema.CheckSchema (connectionString.ConnectionString);\r
+ schemaChecked = true;\r
+\r
+ DerbyUnloadManager.RegisterUnloadHandler (connectionString.ConnectionString, shutDownPolicy);\r
+ }\r
+\r
OleDbConnection connection = new OleDbConnection (connectionString.ConnectionString);\r
connection.Open ();\r
return connection;\r
if (returnValue == 0)\r
return true;\r
if (returnValue == 2)\r
- return false; //role does not exists\r
+ return false; //role does not exist\r
else if (returnValue == 3 && throwOnPopulatedRole)\r
throw new ProviderException (rolename + " is not empty");\r
else\r
int returnValue = DerbyRolesHelper.UsersInRoles_FindUsersInRole (connection, applicationName, roleName, usernameToMatch, out reader);\r
\r
if (returnValue == 2)\r
- throw new ProviderException ("roleName was not found in the database");\r
+ throw new ProviderException ("The role '" + roleName + "' was not found.");\r
\r
using (reader) {\r
if (reader == null)\r
int returnValue = DerbyRolesHelper.UsersInRoles_GetUsersInRoles (connection, applicationName, rolename, out reader);\r
\r
if (returnValue == 2)\r
- throw new ProviderException ("rolename was not found in the database");\r
+ throw new ProviderException ("The role '" + rolename + "' was not found.");\r
\r
using (reader) {\r
if (reader == null)\r
if (connectionString == null)\r
throw new ProviderException (String.Format("The connection name '{0}' was not found in the applications configuration or the connection string is empty.", connectionStringName));\r
\r
- DerbyDBSchema.InitializeSchema (connectionString.ConnectionString);\r
+ string shutdown = config ["shutdown"];\r
+ if (!String.IsNullOrEmpty (shutdown))\r
+ shutDownPolicy = (DerbyUnloadManager.DerbyShutDownPolicy) Enum.Parse (typeof (DerbyUnloadManager.DerbyShutDownPolicy), shutdown, true);\r
}\r
\r
public override bool IsUserInRole (string username, string rolename)\r