// create singleton connection factory.
		internal static DbConnectionFactory GetSingleton (DbProviderFactory pvdrFactory)
		{
			lock (lockobj) {
				if (Instance == null)
					Instance = new SqlConnectionFactory (pvdrFactory);
				return Instance;
			}
		}
Beispiel #2
0
 public static void ChangePassword(string connectionString, string newPassword)
 {
     IntPtr ptr;
     Bid.ScopeEnter(out ptr, "<sc.SqlConnection.ChangePassword|API>");
     try
     {
         if (ADP.IsEmpty(connectionString))
         {
             throw SQL.ChangePasswordArgumentMissing("connectionString");
         }
         if (ADP.IsEmpty(newPassword))
         {
             throw SQL.ChangePasswordArgumentMissing("newPassword");
         }
         if (0x80 < newPassword.Length)
         {
             throw ADP.InvalidArgumentLength("newPassword", 0x80);
         }
         SqlConnectionString connectionOptions = SqlConnectionFactory.FindSqlConnectionOptions(connectionString);
         if (connectionOptions.IntegratedSecurity)
         {
             throw SQL.ChangePasswordConflictsWithSSPI();
         }
         if (!ADP.IsEmpty(connectionOptions.AttachDBFilename))
         {
             throw SQL.ChangePasswordUseOfUnallowedKey("attachdbfilename");
         }
         if (connectionOptions.ContextConnection)
         {
             throw SQL.ChangePasswordUseOfUnallowedKey("context connection");
         }
         connectionOptions.CreatePermissionSet().Demand();
         using (SqlInternalConnectionTds tds = new SqlInternalConnectionTds(null, connectionOptions, null, newPassword, null, false))
         {
             if (!tds.IsYukonOrNewer)
             {
                 throw SQL.ChangePasswordRequiresYukon();
             }
         }
         SqlConnectionFactory.SingletonInstance.ClearPool(connectionString);
     }
     finally
     {
         Bid.ScopeLeave(ref ptr);
     }
 }