Skip to content

Comments

Fix DAC connection issues in linked server operations#10106

Merged
potatoqualitee merged 2 commits intodevelopmentfrom
claude/issue-10040-20260123-1926
Jan 25, 2026
Merged

Fix DAC connection issues in linked server operations#10106
potatoqualitee merged 2 commits intodevelopmentfrom
claude/issue-10040-20260123-1926

Conversation

@potatoqualitee
Copy link
Member

Summary

This PR fixes three related issues with DAC (Dedicated Admin Connection) usage in linked server operations that were causing "maximum number of 1 dedicated administrator connections already exists" errors.

Issue #3 - Root Cause (CRITICAL)

  • Changed Get-DecryptedObject.ps1 to use 127.0.0.1 instead of hostname for local DAC connections
  • Prevents SQL Client from attempting parallel connections to multiple IPs (IPv4, IPv6, localhost)
  • Confirmed working by @edbmfo

Issue #2 - Conditional DAC Usage

  • Modified Copy-DbaLinkedServer.ps1 to only open DAC when passwords are being retrieved
  • When -ExcludePassword is specified, uses regular connection instead
  • Avoids wasting the single available DAC connection

Issue #1 - Missing DAC Connection

  • Added DAC connection establishment to Export-DbaLinkedServer.ps1 when passwords are exported
  • Follows the same pattern as Copy-DbaLinkedServer
  • Includes proper DAC disconnection after processing

Test Plan

  • Test Export-DbaLinkedServer with and without -ExcludePassword
  • Test Copy-DbaLinkedServer with and without -ExcludePassword
  • Verify no DAC errors on servers with multiple network interfaces
  • Test on both clustered and non-clustered instances

Fixes #10040

🤖 Generated with Claude Code

- Fix Issue 3 (root cause): Use 127.0.0.1 instead of hostname in Get-DecryptedObject to prevent SQL Client from attempting parallel connections to multiple IPs, which causes 'maximum number of 1 dedicated administrator connections' error
- Fix Issue 2: Make Copy-DbaLinkedServer conditionally open DAC only when -ExcludePassword is not specified, avoiding unnecessary DAC usage
- Fix Issue 1: Add DAC connection establishment to Export-DbaLinkedServer when passwords are being retrieved

(do *LinkedServer*)

Fixes #10040

Co-authored-by: Chrissy LeMaire <[email protected]>
Copy link
Collaborator

@andreasjordan andreasjordan left a comment

Choose a reason for hiding this comment

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

Code looks good to me. I can try to test this, but it might take some days until I find the time.

}

# Disconnect DAC connection if it was opened
if (-not $ExcludePassword -and $server) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need -and $server here because we only reach this line of code if we made a connection.

Copy link
Member Author

Choose a reason for hiding this comment

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

@claude pls fix

Copy link
Member Author

Choose a reason for hiding this comment

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

(no idea if it works here, lets see)

Copy link

@claude claude bot Jan 24, 2026

Choose a reason for hiding this comment

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

Claude finished @potatoqualitee's task in 1m 7s —— View job


Tasks

  • Read Export-DbaLinkedServer.ps1 to understand the context
  • Remove redundant -and $server condition from line 209
  • Commit and push the fix

Summary

Fixed the redundant condition on line 209. The -and $server check was unnecessary because the code only reaches that point when a DAC connection was successfully established in line 127. The cleanup code now simply checks if (-not $ExcludePassword) which is sufficient.

@andreasjordan
Copy link
Collaborator

Will try to test that today...

Copy link
Collaborator

@andreasjordan andreasjordan left a comment

Choose a reason for hiding this comment

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

I have tested this in my lab and it works as expected.

@potatoqualitee potatoqualitee merged commit a0d6a67 into development Jan 25, 2026
15 checks passed
@potatoqualitee potatoqualitee deleted the claude/issue-10040-20260123-1926 branch January 25, 2026 20:10
@potatoqualitee
Copy link
Member Author

awesome! thank you 🤩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issues with DAC connection

2 participants