Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6921271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:15:20+00:00 2026-05-27T10:15:20+00:00

Perhaps someone can help me out here. I’m writing a program in C# to

  • 0

Perhaps someone can help me out here. I’m writing a program in C# to connect to a database on a remote server. The server in question uses Windows Authentication. I’m also not the admin of the server.

In any event to connect to server using SQL Server Management Studio I have to use a different credentials. So I use the runas.exe to connect.

Basically, Something along the lines of:

runas.exe /netonly /user:DIFFERENT_DOMAIN\SAME_USERNAME “C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe”

Using the runas.exe is the only way I can connect to the database, if I try running ssms without the runas, I will not connect at all.

So now my question. In the program I’m making in C#. How can I get my program to connect to the same database using different credentials without having to use runas.exe?

I’ve tried using:

Sqlconnection sc = new Sqlconnection();
sc.ConnectionString = "Data Source= myServer;Initial Catalog= myDB;Integrated Security=true";
sc.Open();

But I just get “Login failed for user ”. User not associated with a trusted SQL Server Connection.”

If I use the above code and Runas.exe with the correct credentials. It will work fine and connect. However I don’t want to have to use it.

Anyone have any idea how to get the connection to work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:15:20+00:00Added an answer on May 27, 2026 at 10:15 am

    You can impersonate a domain user from your c# code. There are some examples linked from this question:

    Windows Impersonation from C#

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Perhaps someone can help me out with this one: I'm using a basic search
An odd error here, perhaps someone can help track down source as it's attempting
This is not technically a programming question but perhaps someone can help me. Yes,
Perhaps I'm having a Post-Ballmer-Peak Moment . I'm hoping that someone can help point
I have a pretty simple question which perhaps someone familiar with Server/Client design &
Ok so perhaps someone can help me with a problem I'm trying to solve.
Maybe there's someone out in the ether that can help me with this one.
Perhaps someone can point me in the correct direction, because I'm completely stumped on
I'm not sure what this practice is actually called, so perhaps someone can edit
I'm experiencing some weirdness related to an MSI installation upgrade, perhaps someone out there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.