UsersConnectionString() public method

public UsersConnectionString ( bool hidePassword ) : string
hidePassword bool
return string
        private DBConnectionString(DbConnectionOptions connectionOptions, string restrictions, KeyRestrictionBehavior behavior, Hashtable synonyms, bool mustCloneDictionary)   // used by DBDataPermission
        {
            Debug.Assert(null != connectionOptions, "null connectionOptions");
            switch (behavior)
            {
            case KeyRestrictionBehavior.PreventUsage:
            case KeyRestrictionBehavior.AllowOnly:
                _behavior = behavior;
                break;

            default:
                throw ADP.InvalidKeyRestrictionBehavior(behavior);
            }

            // grab all the parsed details from DbConnectionOptions
            _encryptedUsersConnectionString = connectionOptions.UsersConnectionString(false);
            _hasPassword = connectionOptions.HasPasswordKeyword;
            _parsetable  = connectionOptions.Parsetable;
            _keychain    = connectionOptions._keyChain;

            // we do not want to serialize out user password unless directed so by "persist security info=true"
            // otherwise all instances of user's password will be replaced with "*"
            if (_hasPassword && !connectionOptions.HasPersistablePassword)
            {
                if (mustCloneDictionary)
                {
                    // clone the hashtable to replace user's password/pwd value with "*"
                    // we only need to clone if coming from DbConnectionOptions and password exists
                    _parsetable = (Hashtable)_parsetable.Clone();
                }

                // different than Everett in that instead of removing password/pwd from
                // the hashtable, we replace the value with '*'.  This is okay since we
                // serialize out with '*' so already knows what we do.  Better this way
                // than to treat password specially later on which causes problems.
                const string star = "*";
                if (_parsetable.ContainsKey(KEY.Password))
                {
                    _parsetable[KEY.Password] = star;
                }
                if (_parsetable.ContainsKey(KEY.Pwd))
                {
                    _parsetable[KEY.Pwd] = star;
                }

                // replace user's password/pwd value with "*" in the linked list and build a new string
                _keychain = connectionOptions.ReplacePasswordPwd(out _encryptedUsersConnectionString, true);
            }

            if (!ADP.IsEmpty(restrictions))
            {
                _restrictionValues = ParseRestrictions(restrictions, synonyms);
                _restrictions      = restrictions;
            }
        }
Exemplo n.º 2
0
        private DBConnectionString(DbConnectionOptions connectionOptions, string restrictions, KeyRestrictionBehavior behavior, Hashtable synonyms, bool mustCloneDictionary)
        {
            Debug.Assert(null != connectionOptions, "null connectionOptions");
            switch (behavior)
            {
                case KeyRestrictionBehavior.PreventUsage:
                case KeyRestrictionBehavior.AllowOnly:
                    _behavior = behavior;
                    break;
                default:
                    throw ADP.InvalidKeyRestrictionBehavior(behavior);
            }

            // grab all the parsed details from DbConnectionOptions
            _encryptedUsersConnectionString = connectionOptions.UsersConnectionString(false);
            _hasPassword = connectionOptions._hasPasswordKeyword;
            _parsetable = connectionOptions.Parsetable;
            _keychain = connectionOptions._keyChain;

            // we do not want to serialize out user password unless directed so by "persist security info=true"
            // otherwise all instances of user's password will be replaced with "*"
            if (_hasPassword && !connectionOptions.HasPersistablePassword)
            {
                if (mustCloneDictionary)
                {
                    // clone the hashtable to replace user's password/pwd value with "*"
                    // we only need to clone if coming from DbConnectionOptions and password exists
                    _parsetable = (Hashtable)_parsetable.Clone();
                }

                // different than Everett in that instead of removing password/pwd from
                // the hashtable, we replace the value with '*'.  This is okay since we
                // serialize out with '*' so already knows what we do.  Better this way
                // than to treat password specially later on which causes problems.
                const string star = "*";
                if (_parsetable.ContainsKey(KEY.Password))
                {
                    _parsetable[KEY.Password] = star;
                }
                if (_parsetable.ContainsKey(KEY.Pwd))
                {
                    _parsetable[KEY.Pwd] = star;
                }

                // replace user's password/pwd value with "*" in the linked list and build a new string
                _keychain = connectionOptions.ReplacePasswordPwd(out _encryptedUsersConnectionString, true);
            }

            if (!string.IsNullOrEmpty(restrictions))
            {
                _restrictionValues = ParseRestrictions(restrictions, synonyms);
                _restrictions = restrictions;
            }
        }
Exemplo n.º 3
0
        private string ConnectionString_Get()
        {
            Bid.Trace("<prov.DbConnectionHelper.ConnectionString_Get|API> %d#\n", this.ObjectID);
            bool shouldHidePassword = this.InnerConnection.ShouldHidePassword;

            System.Data.Common.DbConnectionOptions userConnectionOptions = this.UserConnectionOptions;
            if (userConnectionOptions == null)
            {
                return("");
            }
            return(userConnectionOptions.UsersConnectionString(shouldHidePassword));
        }
 private System.Data.ProviderBase.DbConnectionPool GetConnectionPool(DbConnection owningObject, System.Data.ProviderBase.DbConnectionPoolGroup connectionPoolGroup)
 {
     if (connectionPoolGroup.IsDisabled && (connectionPoolGroup.PoolGroupOptions != null))
     {
         Bid.Trace("<prov.DbConnectionFactory.GetConnectionPool|RES|INFO|CPOOL> %d#, DisabledPoolGroup=%d#\n", this.ObjectID, connectionPoolGroup.ObjectID);
         System.Data.ProviderBase.DbConnectionPoolGroupOptions poolGroupOptions = connectionPoolGroup.PoolGroupOptions;
         System.Data.Common.DbConnectionOptions connectionOptions = connectionPoolGroup.ConnectionOptions;
         string connectionString = connectionOptions.UsersConnectionString(false);
         connectionPoolGroup = this.GetConnectionPoolGroup(connectionString, poolGroupOptions, ref connectionOptions);
         this.SetConnectionPoolGroup(owningObject, connectionPoolGroup);
     }
     return(connectionPoolGroup.GetConnectionPool(this));
 }
Exemplo n.º 5
0
 private DBConnectionString(DbConnectionOptions connectionOptions, string restrictions, KeyRestrictionBehavior behavior, Hashtable synonyms, bool mustCloneDictionary)
 {
     switch (behavior)
     {
     case KeyRestrictionBehavior.AllowOnly:
     case KeyRestrictionBehavior.PreventUsage:
         this._behavior = behavior;
         this._encryptedUsersConnectionString = connectionOptions.UsersConnectionString(false);
         this._hasPassword = connectionOptions.HasPasswordKeyword;
         this._parsetable  = connectionOptions.Parsetable;
         this._keychain    = connectionOptions.KeyChain;
         if (this._hasPassword && !connectionOptions.HasPersistablePassword)
         {
             if (mustCloneDictionary)
             {
                 this._parsetable = (Hashtable)this._parsetable.Clone();
             }
             if (this._parsetable.ContainsKey("password"))
             {
                 this._parsetable["password"] = "******";
             }
             if (this._parsetable.ContainsKey("pwd"))
             {
                 this._parsetable["pwd"] = "*";
             }
             this._keychain = connectionOptions.ReplacePasswordPwd(out this._encryptedUsersConnectionString, true);
         }
         if (!ADP.IsEmpty(restrictions))
         {
             this._restrictionValues = ParseRestrictions(restrictions, synonyms);
             this._restrictions      = restrictions;
         }
         return;
     }
     throw ADP.InvalidKeyRestrictionBehavior(behavior);
 }