示例#1
0
 internal OdbcPermission(OdbcConnectionString constr) : base(constr)
 { // for Open
     if ((null == constr) || constr.IsEmpty)
     {
         base.Add(ADP.StrEmpty, ADP.StrEmpty, KeyRestrictionBehavior.AllowOnly);
     }
 }
        override protected DbConnectionOptions CreateConnectionOptions(string connectionString, DbConnectionOptions previous)
        {
            Debug.Assert(!ADP.IsEmpty(connectionString), "empty connectionString");
            OdbcConnectionString result = new OdbcConnectionString(connectionString, (null != previous));

            return(result);
        }
示例#3
0
        static internal OdbcConnectionString ParseString(string connectionString) {
            OdbcConnectionString constr = null;
            if (!ADP.IsEmpty(connectionString)) {

                constr = (DBConnectionString.CacheQuery(connectionString, _odbcParseCache) as OdbcConnectionString);
                if (null == constr) {
#if USECRYPTO
                    string encrypted = null/*Crypto.EncryptString(connectionString)*/;
                    string hashvalue = (null == encrypted) ? Crypto.ComputeHash(connectionString) : encrypted;
                    constr = (DBConnectionString.CacheQuery(hashvalue, _odbcParseCache) as OdbcConnectionString);
                    if (null == constr) {
                        constr = new OdbcConnectionString(connectionString, encrypted);
#else
                        constr = new OdbcConnectionString(connectionString);
#endif
                         if (constr.ShouldCache()) {
#if USECRYPTO
                            if (!constr.IsEncrypted) {
                                hashvalue = connectionString;
                            }
                            CacheAdd(hashvalue, constr, ref _odbcParseCache);
#else
                            CacheAdd(connectionString, constr, ref _odbcParseCache);
#endif
                         }
#if USECRYPTO
                    }
#endif
                }
            }
            return constr;
        }
 internal OdbcPermission(OdbcConnectionString constr) : base(constr)
 {
     if ((constr == null) || constr.IsEmpty)
     {
         base.Add(ADP.StrEmpty, ADP.StrEmpty, KeyRestrictionBehavior.AllowOnly);
     }
 }
示例#5
0
        internal OdbcConnectionHandle(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle) : base(ODBC32.SQL_HANDLE.DBC, environmentHandle)
        {
            if (null == connection)
            {
                throw ADP.ArgumentNull("connection");
            }
            if (null == constr)
            {
                throw ADP.ArgumentNull("constr");
            }

            ODBC32.RetCode retcode;

            //Set connection timeout (only before open).
            //Note: We use login timeout since its odbc 1.0 option, instead of using
            //connectiontimeout (which affects other things besides just login) and its
            //a odbc 3.0 feature.  The ConnectionTimeout on the managed providers represents
            //the login timeout, nothing more.
            int connectionTimeout = connection.ConnectionTimeout;

            retcode = SetConnectionAttribute2(ODBC32.SQL_ATTR.LOGIN_TIMEOUT, (IntPtr)connectionTimeout, (Int32)ODBC32.SQL_IS.UINTEGER);

            string connectionString = constr.UsersConnectionString(false);

            // Connect to the driver.  (Using the connection string supplied)
            //Note: The driver doesn't filter out the password in the returned connection string
            //so their is no need for us to obtain the returned connection string
            // Prepare to handle a ThreadAbort Exception between SQLDriverConnectW and update of the state variables
            retcode = Connect(connectionString);
            connection.HandleError(this, retcode);
        }
        internal OdbcConnectionHandle(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle) : base(ODBC32.SQL_HANDLE.DBC, environmentHandle) {
            if(null == connection) {
                throw ADP.ArgumentNull("connection");
            }
            if(null == constr) {
                throw ADP.ArgumentNull("constr");
            }

            ODBC32.RetCode retcode;

            //Set connection timeout (only before open).
            //Note: We use login timeout since its odbc 1.0 option, instead of using
            //connectiontimeout (which affects other things besides just login) and its
            //a odbc 3.0 feature.  The ConnectionTimeout on the managed providers represents
            //the login timeout, nothing more.
            int connectionTimeout = connection.ConnectionTimeout;
            retcode = SetConnectionAttribute2(ODBC32.SQL_ATTR.LOGIN_TIMEOUT, (IntPtr)connectionTimeout, (Int32)ODBC32.SQL_IS.UINTEGER);

            string connectionString = constr.UsersConnectionString(false);

            // Connect to the driver.  (Using the connection string supplied)
            //Note: The driver doesn't filter out the password in the returned connection string
            //so their is no need for us to obtain the returned connection string
            // Prepare to handle a ThreadAbort Exception between SQLDriverConnectW and update of the state variables
            retcode = Connect(connectionString);
            connection.HandleError(this, retcode);
        }
        /// <include file='doc\OdbcPermission.uex' path='docs/doc[@for="OdbcPermission.Add"]/*' />
        override public void Add(string connectionString, string restrictions, KeyRestrictionBehavior behavior)
        {
            switch (behavior)
            {
            case KeyRestrictionBehavior.PreventUsage:
            case KeyRestrictionBehavior.AllowOnly:
                break;

            default:
                throw ADP.Argument("value");
            }
            DBConnectionString entry = new OdbcConnectionString(connectionString, restrictions, behavior); // MDAC 85142

            base.AddPermissionEntry(entry);
        }
 internal OdbcConnectionHandle(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle) : base(ODBC32.SQL_HANDLE.DBC, environmentHandle)
 {
     if (connection == null)
     {
         throw ADP.ArgumentNull("connection");
     }
     if (constr == null)
     {
         throw ADP.ArgumentNull("constr");
     }
     int connectionTimeout = connection.ConnectionTimeout;
     ODBC32.RetCode retcode = this.SetConnectionAttribute2(ODBC32.SQL_ATTR.LOGIN_TIMEOUT, (IntPtr) connectionTimeout, -5);
     string connectionString = constr.UsersConnectionString(false);
     retcode = this.Connect(connectionString);
     connection.HandleError(this, retcode);
 }
示例#9
0
 static internal PermissionSet CreatePermission(OdbcConnectionString constr) {
     OdbcPermission p = new OdbcPermission(constr);
     if (null == constr) {
         p.Add("", "", KeyRestrictionBehavior.AllowOnly); // ExecuteOnly permission
     }
     PermissionSet permission;
     NamedPermissionSet fulltrust = new NamedPermissionSet("FullTrust"); // MDAC 83159
     fulltrust.Assert();
     try {
         permission = new PermissionSet(fulltrust);
         permission.AddPermission(p);
     }
     finally {
         CodeAccessPermission.RevertAssert();
     }
     return permission;
 }
        // Construct from a compiled connection string
        internal OdbcConnectionOpen(OdbcConnection outerConnection, OdbcConnectionString connectionOptions) {
#if DEBUG
            try { // use this to help validate this object is only created after the following permission has been previously demanded in the current codepath
                if (null != outerConnection) {
                    outerConnection.UserConnectionOptions.DemandPermission();
                }
                else {
                    connectionOptions.DemandPermission();
                }
            }
            catch(System.Security.SecurityException) {
                System.Diagnostics.Debug.Assert(false, "unexpected SecurityException for current codepath");
                throw;
            }
#endif
            OdbcEnvironmentHandle environmentHandle = OdbcEnvironment.GetGlobalEnvironmentHandle();
            outerConnection.ConnectionHandle = new OdbcConnectionHandle(outerConnection, connectionOptions, environmentHandle);
        }
        internal OdbcConnectionHandle(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle) : base(ODBC32.SQL_HANDLE.DBC, environmentHandle)
        {
            if (connection == null)
            {
                throw ADP.ArgumentNull("connection");
            }
            if (constr == null)
            {
                throw ADP.ArgumentNull("constr");
            }
            int connectionTimeout = connection.ConnectionTimeout;

            ODBC32.RetCode retcode          = this.SetConnectionAttribute2(ODBC32.SQL_ATTR.LOGIN_TIMEOUT, (IntPtr)connectionTimeout, -5);
            string         connectionString = constr.UsersConnectionString(false);

            retcode = this.Connect(connectionString);
            connection.HandleError(this, retcode);
        }
示例#12
0
        // Construct from a compiled connection string
        internal OdbcConnectionOpen(OdbcConnection outerConnection, OdbcConnectionString connectionOptions)
        {
#if DEBUG
            try { // use this to help validate this object is only created after the following permission has been previously demanded in the current codepath
                if (null != outerConnection)
                {
                    outerConnection.UserConnectionOptions.DemandPermission();
                }
                else
                {
                    connectionOptions.DemandPermission();
                }
            }
            catch (System.Security.SecurityException) {
                System.Diagnostics.Debug.Assert(false, "unexpected SecurityException for current codepath");
                throw;
            }
#endif
            OdbcEnvironmentHandle environmentHandle = OdbcEnvironment.GetGlobalEnvironmentHandle();
            outerConnection.ConnectionHandle = new OdbcConnectionHandle(outerConnection, connectionOptions, environmentHandle);
        }
 internal OdbcPermission(OdbcConnectionString constr) : base(constr)   // for Open
 {
 }
 override protected DbConnectionOptions CreateConnectionOptions(string connectionString, DbConnectionOptions previous) {
     Debug.Assert(!ADP.IsEmpty(connectionString), "empty connectionString");
     OdbcConnectionString result = new OdbcConnectionString(connectionString, (null != previous));
     return result;
 }
示例#15
0
        // Construct from a compiled connection string
        internal OdbcConnectionOpen(OdbcConnection outerConnection, OdbcConnectionString connectionOptions)
        {
            OdbcEnvironmentHandle environmentHandle = OdbcEnvironment.GetGlobalEnvironmentHandle();

            outerConnection.ConnectionHandle = new OdbcConnectionHandle(outerConnection, connectionOptions, environmentHandle);
        }
示例#16
0
        private OdbcConnectionString(string connectionString) : base(connectionString, UdlSupport.ThrowIfFound) {
#endif
            _permission = OdbcConnectionString.CreatePermission(this);
        }
 internal OdbcConnectionOpen(OdbcConnection outerConnection, OdbcConnectionString connectionOptions)
 {
     OdbcEnvironmentHandle globalEnvironmentHandle = OdbcEnvironment.GetGlobalEnvironmentHandle();
     outerConnection.ConnectionHandle = new OdbcConnectionHandle(outerConnection, connectionOptions, globalEnvironmentHandle);
 }
示例#18
0
 static internal void Demand(OdbcConnectionString constr) {
     PermissionSet permission = ((null != constr) ? constr._permission : OdbcConnection.OdbcPermission);
     permission.Demand();
 }