* DerbyProfileProvider.cs: fixed Initialize, CreateConnection throw exception if...
authorVladimir Krasnov <krasnov@mono-cvs.ximian.com>
Wed, 21 Feb 2007 16:32:28 +0000 (16:32 -0000)
committerVladimir Krasnov <krasnov@mono-cvs.ximian.com>
Wed, 21 Feb 2007 16:32:28 +0000 (16:32 -0000)
* DerbyMembershipProvider.cs: fixed Initialize, throw exception if no connection string present

svn path=/trunk/mcs/; revision=73259

mcs/class/Mainsoft.Web/Mainsoft.Web.Profile/ChangeLog
mcs/class/Mainsoft.Web/Mainsoft.Web.Profile/DerbyProfileProvider.cs
mcs/class/Mainsoft.Web/Mainsoft.Web.Security/ChangeLog
mcs/class/Mainsoft.Web/Mainsoft.Web.Security/DerbyMembershipProvider.cs

index d93df4eda1aaabc9e9f1d65bd064c8a0dfeb012a..1f87c64e3d7f05fa849c572d831c240ebd826d03 100644 (file)
@@ -1,3 +1,8 @@
+2007-02-21  Vladimir Krasnov  <vladimirk@mainsoft.com>\r
+\r
+       * DerbyProfileProvider.cs: fixed Initialize, CreateConnection throw\r
+       exception if no connection string present\r
+\r
 2007-01-15  Vladimir Krasnov  <vladimirk@mainsoft.com>\r
 \r
        * DerbyProfileHelper.cs: fixed GetUserId, return null if username\r
index de7f667c2d22bcf575624a263988919421438da8..ed0727118f3fcfb6458a6a2bf7fd6587ba65bb9c 100644 (file)
@@ -35,7 +35,8 @@ using System.Collections;
 using System.Configuration;\r
 using System.Globalization;\r
 using System.Web.Profile;\r
-using System.Web.Configuration;
+using System.Web.Configuration;\r
+using System.Configuration.Provider;
 using System.Collections.Specialized;\r
 using System.Text;\r
 using System.IO;\r
@@ -47,7 +48,8 @@ namespace Mainsoft.Web.Profile
        public class DerbyProfileProvider : ProfileProvider
        {\r
                ConnectionStringSettings _connectionString;\r
-               string _applicationName = "";
+               string _connectionStringName = string.Empty;\r
+               string _applicationName = string.Empty;
 
                public DerbyProfileProvider ()
                {
@@ -61,6 +63,9 @@ namespace Mainsoft.Web.Profile
 \r
                DbConnection CreateConnection ()\r
                {\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.CheckSchema (_connectionString.ConnectionString);\r
 \r
                        OleDbConnection connection = new OleDbConnection (_connectionString.ConnectionString);\r
@@ -307,10 +312,17 @@ namespace Mainsoft.Web.Profile
                        _applicationName = GetStringConfigValue (config, "applicationName", "/");\r
 \r
                        ProfileSection profileSection = (ProfileSection) WebConfigurationManager.GetSection ("system.web/profile");\r
-                       string connectionStringName = config ["connectionStringName"];\r
-                       _connectionString = WebConfigurationManager.ConnectionStrings [connectionStringName];\r
+                       _connectionStringName = config ["connectionStringName"];\r
+                       \r
+                       if (_applicationName.Length > 256)\r
+                               throw new ProviderException ("The ApplicationName attribute must be 256 characters long or less.");\r
+                       if (_connectionStringName == null || _connectionStringName.Length == 0)\r
+                               throw new ProviderException ("The ConnectionStringName attribute must be present and non-zero length.");
 \r
-                       DerbyDBSchema.RegisterUnloadHandler (_connectionString.ConnectionString);\r
+                       _connectionString = WebConfigurationManager.ConnectionStrings [_connectionStringName];\r
+\r
+                       if (_connectionString != null)\r
+                               DerbyDBSchema.RegisterUnloadHandler (_connectionString.ConnectionString);\r
                }\r
 \r
                private ProfileInfoCollection BuildProfileInfoCollection (DbDataReader reader, int pageIndex, int pageSize, out int totalRecords)\r
index b5f4ac1f8d112c80f58fc1fe3cc99bacfce40c97..90f0c5b62686c11ecd3837e6bc95def08a311860 100644 (file)
@@ -1,3 +1,8 @@
+2007-02-21  Vladimir Krasnov  <vladimirk@mainsoft.com>\r
+\r
+       * DerbyMembershipProvider.cs: fixed Initialize, throw exception if no\r
+       connection string present\r
+\r
 2007-01-18  Vladimir Krasnov  <vladimirk@mainsoft.com>\r
 \r
        * DerbyDBSchema.cs: added traces to unload handler\r
index f07114dc0e3f6cd409091a0b955302214cdf1bdb..ab885ad29d3bc8414e62aa500c690d5694b0b9df 100644 (file)
@@ -601,6 +601,8 @@ namespace Mainsoft.Web.Security {
                                throw new ProviderException ("The ConnectionStringName attribute must be present and non-zero length.");
 
                        connectionString = WebConfigurationManager.ConnectionStrings [connectionStringName];\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.RegisterUnloadHandler (connectionString.ConnectionString);\r
                }