run commands using credentials of different domains

E

Eigh

Hi.

I'm trying to establish a connection to an SQL 2005 server using different
credentials than the ones currently in use. The server only allows Windows
Authentication, so I have to impersonate a different user. Setting
impersonation on the web.config isn't an option. Moreover, the Sql server
is on a different domain than the code that I am running the webapp on.

I've confirmed with absolute certainty that the credentials that I am using
to try to login remotely DO have access to login to the remote sql server by
logging in using "runas /netonly /user:domain\user sqlwb"

In code, I've tried impersonating a different user using
WindowsIdentity.Impersonate, but I get error 1326 when executing
LoginUser(lpszUsername, lpszDomain, lpszPassword, dwLoginType,
dwLoginprovider, phToken).

I assume the error comes from trying to authenticate credentials that my
workstation doesn't have access to. How else can I authenticate a user
account across the network using credentials on a domain that my machine is
not logged into?

Any help would be appreciated.

thanks,

Eigh
 
J

Joe Kaplan

If runas with /netonly works for you, then it seems like you should be able
to call LogonUser with LOGON32_LOGON_NEW_CREDENTIALS (9) and get similar
results. What are you passing in for the logon type that isn't working?

Joe K.
 
E

Eigh

I _WAS_ using 2. I switched it over to using 9 and now it works like a
charm.

Thanks Joe!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top