Skip to content

Comments

Expose SSPI context provider as public#2494

Merged
cheenamalhotra merged 16 commits intodotnet:mainfrom
twsouthwick:public
Feb 19, 2026
Merged

Expose SSPI context provider as public#2494
cheenamalhotra merged 16 commits intodotnet:mainfrom
twsouthwick:public

Conversation

@twsouthwick
Copy link
Member

@twsouthwick twsouthwick commented May 8, 2024

This change:

  • Adds a property to SqlConnection to allow setting a provider
  • Plumbs that property into the TdsParser so that it can be used if set

Fixes #2253

@twsouthwick twsouthwick changed the title Expose SSPI context provider as public Expose SSPI context provider as public May 8, 2024
@twsouthwick twsouthwick force-pushed the public branch 3 times, most recently from e16f2c8 to cfcf164 Compare March 3, 2025 19:42
@codecov
Copy link

codecov bot commented Mar 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (28caf4c) to head (05d4a8d).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #2494       +/-   ##
==========================================
- Coverage   90.82%       0   -90.83%     
==========================================
  Files           6       0        -6     
  Lines         316       0      -316     
==========================================
- Hits          287       0      -287     
+ Misses         29       0       -29     
Flag Coverage Δ
addons ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@benrr101 benrr101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, really like the goal and implementation. Most of my comments are style related, since I'm sure my colleagues have tackled the bigger questions.

Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made an initial pass, and came up with some questions/comments.

@paulmedynski paulmedynski self-assigned this Apr 2, 2025
@twsouthwick twsouthwick force-pushed the public branch 6 times, most recently from 380e896 to 2039bd9 Compare May 1, 2025 19:37
Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Factory vs instance in the netfx code, and a few questions about docs.

@twsouthwick twsouthwick force-pushed the public branch 4 times, most recently from 5bb128f to 8937cb7 Compare May 13, 2025 14:58
@twsouthwick twsouthwick marked this pull request as ready for review May 13, 2025 18:40
Copy link

@nhart12 nhart12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest package still works for our use-case

mdaigle
mdaigle previously approved these changes Feb 12, 2026
Copilot AI review requested due to automatic review settings February 12, 2026 23:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnection.cs:807

  • The SspiContextProvider property setter is missing critical validation that exists in other similar properties (Credential, AccessToken, AccessTokenCallback). Since this property affects the connection pool key, it must validate that the connection is not already open or opening before allowing the value to be changed.

Add the following validation at the start of the setter:

if (!InnerConnection.AllowSetConnectionString)
{
    throw ADP.OpenConnectionPropertySet(nameof(SspiContextProvider), InnerConnection.State);
}

This prevents runtime errors when users attempt to change the SSPI provider on an active connection and maintains consistency with the established pattern for pool-key-affecting properties.

        public SspiContextProvider SspiContextProvider
        {
            get { return _sspiContextProvider; }
            set
            {
                ConnectionString_Set(new SqlConnectionPoolKey(_connectionString, credential: _credential, accessToken: null, accessTokenCallback: null, sspiContextProvider: value));
                _sspiContextProvider = value;
            }
        }

@github-actions github-actions bot removed the Stale The Issue or PR has become stale and will be automatically closed shortly if no activity occurs. label Feb 13, 2026
Copilot AI review requested due to automatic review settings February 13, 2026 19:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnection.cs:806

  • The SspiContextProvider property setter is missing validation that prevents modification after the connection is opened. Connection-level properties that affect the pool key (Credential, AccessToken, AccessTokenCallback) must validate InnerConnection.AllowSetConnectionString and throw ADP.OpenConnectionPropertySet if false. The documentation at line 2145 explicitly states "The SspiContextProvider is a part of the connection pool key", so it must follow the same pattern. Add the validation check at the start of the setter, similar to the AccessTokenCallback property at lines 782-784.
        public SspiContextProvider SspiContextProvider
        {
            get { return _sspiContextProvider; }
            set
            {
                ConnectionString_Set(new SqlConnectionPoolKey(_connectionString, credential: _credential, accessToken: null, accessTokenCallback: null, sspiContextProvider: value));
                _sspiContextProvider = value;
            }

Copilot AI review requested due to automatic review settings February 13, 2026 21:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.

cheenamalhotra
cheenamalhotra previously approved these changes Feb 13, 2026
@paulmedynski paulmedynski removed the Partner Approval Needed 🤝 Issues/PRs that require approval/feedback from partner teams label Feb 18, 2026
@mdaigle mdaigle dismissed benrr101’s stale review February 18, 2026 23:58

Comments have been addressed. Dismissing because Ben is out of town and unavailable for a new review.

@cheenamalhotra cheenamalhotra merged commit 35aa62a into dotnet:main Feb 19, 2026
295 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Public API 🆕 Issues/PRs that introduce new APIs to the driver.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add hook for custom SSPI context for SqlConnection instances

8 participants