WCF service hosted in IIS7 with administrator rights

iis-7permissionswcf

How do I grant administrator rights to a running WCF service hosted in IIS7?

The problem is, my code works fine in a test console application runned as an administrator, but the same code used from WCF service in IIS7 fails.
When I run the same console test application without admin rights, code fails.

So, how do I grant admin rights to a WCF service hosted in IIS7?
Do I grant admin rights to IIS7 service? Can I grant rights to a specific WCF service? How do I do 'Run as an administrator' on IIS7 or specific website?

Thanks!

(That's the question, here is a more detailed description of a situation:
I am trying to capture frames from a webcam into a jpg file using Touchless library, and I can do that from a console application with admin rights.
When I run that same console app without admin rights I cannot access a webcam in code. Same thing happens in a WCF service with the same code.)

Best Answer

The permissions that your WCF service is running under is most likely the application pool identity. First, be careful with granting admin rights to an app pool. I would separate this service to it's own app pool if you can to minimize the footprint of what needs admin rights.

Visit the app pool and go to advanced settings in the Actions pane. You can set your own custom admin user there.

Also, there's a chance that part of the service runs as the anonymous user's account. To change that edit the site and then authorization -> anonymous. Set it to use the app pool identity. That way everything will run under the identity set in the app pool.

Related Topic