run commands using credentials of different domains

Discussion in 'ASP .Net Security' started by Eigh, Aug 10, 2008.

  1. Eigh

    Eigh Guest

    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
     
    Eigh, Aug 10, 2008
    #1
    1. Advertising

  2. Eigh

    Joe Kaplan Guest

    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.
    --
    Joe Kaplan-MS MVP Directory Services Programming
    Co-author of "The .NET Developer's Guide to Directory Services Programming"
    http://www.directoryprogramming.net
    --
    "Eigh" <> wrote in message
    news:...
    > 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
    >
    >
    >
     
    Joe Kaplan, Aug 10, 2008
    #2
    1. Advertising

  3. Eigh

    Eigh Guest

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

    Thanks Joe!

    "Joe Kaplan" wrote:

    > 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.
    > --
    > Joe Kaplan-MS MVP Directory Services Programming
    > Co-author of "The .NET Developer's Guide to Directory Services Programming"
    > http://www.directoryprogramming.net
    > --
    > "Eigh" <> wrote in message
    > news:...
    > > 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
    > >
    > >
    > >

    >
    >
    >
     
    Eigh, Aug 11, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ian
    Replies:
    4
    Views:
    1,529
    Lewis Wang [MSFT]
    Aug 14, 2003
  2. Ben Pfaff

    Re: man pages for C commands (GCC commands)

    Ben Pfaff, Jun 24, 2003, in forum: C Programming
    Replies:
    4
    Views:
    3,999
    Thomas Stegen
    Jun 28, 2003
  3. Tim Stanka
    Replies:
    1
    Views:
    828
    Jeff Epler
    Aug 2, 2004
  4. Andy Klare

    File.Move() using different credentials?

    Andy Klare, Nov 30, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    768
    Andy Klare
    Nov 30, 2006
  5. Jonas Daunoravicius
    Replies:
    0
    Views:
    135
    Jonas Daunoravicius
    Jan 19, 2004
Loading...

Share This Page