예제 #1
0
 public void Remove(DatabaseProfile profile)
 {
     if (BaseIndexOf(profile) >= 0)
     {
         BaseRemove(profile.Name);
     }
 }
예제 #2
0
        /// <summary>
        /// Impersonate this SecurityContext
        /// </summary>
        /// <param name="state">State supplied by the caller</param>
        /// <returns><c>null</c></returns>
        /// <remarks>
        /// <para>
        /// No impersonation is done and <c>null</c> is always returned.
        /// </para>
        /// </remarks>
        public override IDisposable Impersonate(object state)
        {
            DatabaseProfile profile = state as DatabaseProfile;

            if (profile == null)
            {
                throw new ArgumentException("state", "The state must be a DBProfile object.");
            }

            // Here we want to impersonate the user that is trying to connect.
            // If they want to use windows authentication, we need to impersonate the user and set the connection string attribute.
            if (_useWindowsAuthentication)
            {
                // Tell the profile we are using windows impersonation
                if (profile.ProviderType == "SQL")
                {
                    profile.ConnectionStringBuilder.Add("Integrated Security", "SSPI");
                }
                if (_securityContext == null)
                {
                    return(new DisposableImpersonationContext(profile, new WindowsSecurityContext().Impersonate(state)));
                }
                else
                {
                    return(new DisposableImpersonationContext(profile, _securityContext.Impersonate(state)));
                }
            }
            else
            {
                profile.ConnectionStringBuilder.Add("UID", _userName);
                profile.ConnectionStringBuilder.Add("PWD", _password);
                return(new DisposableImpersonationContext(profile, null));
            }
        }
예제 #3
0
        /// <summary>
        /// Creates a copy of the database profile into a new database profile.
        /// </summary>
        /// <returns></returns>
        public DatabaseProfile Copy()
        {
            DatabaseProfile copySetting = new DatabaseProfile();

            foreach (ConfigurationProperty property in this.Properties)
            {
                copySetting[property.Name] = this[property.Name];
            }
            copySetting.ConnectionString = this.ConnectionString;
            return(copySetting);
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SqlQuery"/> class with a database profile <see cref="DatabaseProfile"/>.
 /// </summary>
 /// <param name="profile">The database profile that contains the connection to the database.</param>
 public SqlQuery(DatabaseProfile profile)
     : base(profile)
 {
 }
예제 #5
0
 public void Add(DatabaseProfile profile)
 {
     BaseAdd(profile);
 }
예제 #6
0
 public int IndexOf(DatabaseProfile profile)
 {
     return(BaseIndexOf(profile));
 }
예제 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OleDbQuery"/> class with a database profile <see cref="DatabaseProfile"/>.
 /// </summary>
 /// <param name="profile">The database profile that contains the connection to the database.</param>
 public OleDbQuery(DatabaseProfile profile)
     : base(profile)
 {
 }
예제 #8
0
 public QueryBase CreateQuery(DatabaseProfile profile)
 {
     return(new OdbcQuery(profile));
 }
예제 #9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="profile">The database profile to use impersonation for.</param>
 /// <param name="impersonationContext">the impersonation context being wrapped</param>
 /// <remarks>
 /// <para>
 /// Constructor
 /// </para>
 /// </remarks>
 public DisposableImpersonationContext(DatabaseProfile profile, IDisposable impersonationContext)
 {
     _profile = profile;
     _contextImpersonation = impersonationContext;
 }
예제 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OdbcQuery"/> class with a database profile <see cref="DatabaseProfile"/>.
 /// </summary>
 /// <param name="profile">The database profile that contains the connection to the database.</param>
 public OdbcQuery(DatabaseProfile profile)
     : base(profile)
 {
 }
예제 #11
0
 /// <summary>
 /// Gets the ProviderPlugin associated with the provider type specified
 /// </summary>
 /// <param name="profile">The DatabaseProfile to use to find the provider plugin.</param>
 /// <returns></returns>
 public static IProviderPlugin GetProviderPlugin(DatabaseProfile profile)
 {
     return(Plugin.PluginManager.GetPluginByProviderType(profile.ProviderType));
 }