Control a service on a remote server from IIS
Asked Answered
M

2

1

Please note: In each step I describe below I'm logged in as the same domain user account.

I have a web application that controls a service on a remote machine (via ServiceController). When I connect to the website remotely and attempt to control the service, I get an InvalidOperationException: Access is denied.

I know it CAN work, because when I connect to the website from the web server (remote desktop in, login as my domain user, then open the webpage), it works as expected.

I have configured IIS and ASP.NET to require windows authentication and impersonation. I log the current thread's principal when this fails, and I see that the thread is running under my identity whether I'm connecting remotely or from the server itself.

I have tried forcing IIS to use Kerberos authentication, NTLM authentication and both at the same time; whether my principal reports its AuthenticationType as "Negotiate" or "NTLM" it doesn't matter. None of them work when I connect remotely (from my local machine)

ANOTHER weird thing about this is that if I'm debugging from my local machine/connecting to the remote server, it works every time! But I'm NOT debugging, it fails every time!

What in the heck could be going on here?

Microprint answered 26/11, 2008 at 19:53 Comment(0)
R
1

Your scenario is delegation and not impersonation. Delegation is hard to achieve and it depends on many thing that are done right.

A place to start would be Kerberos authentication and troubleshooting delegation issues

David Wang blog is a very useful resource on thous issues.

Renunciation answered 26/11, 2008 at 20:16 Comment(0)
E
0

"ANOTHER weird thing about this is that if I'm debugging from my local machine/connecting to the remote server, it works every time! But I'm NOT debugging, it fails every time!"

That's a clear indication that you have permission issues. When you run in the debugger you're running as the logged on user, when you're not debugging it runs as whatever IIS is set to use (NETWORK SERVICE by default). Try setting (temporarily!) the Enable anonymous access using your domain account as the user and see if that works. If it does then it means your IIS is not setup properly to impersonate (and it's probably running as NETWORK SERVICE).

Permissions in IIS can be a bitch to fine tune properly... Good luck!

P/S: This looks more like a network administration question than a programming one (see https://stackoverflow.com/questions/321618/stackoverflow-is-for-programming-questions-here-are-some-better-forums-for-your#321756)

Enmity answered 26/11, 2008 at 20:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.