LockWorkStation and WTSLogoffSession return error code 5 in a Vist

  • Thread starter Thread starter Santosh Panchapakesan
  • Start date Start date
S

Santosh Panchapakesan

Hi,

I have written a service with "requestedExecutionLevel
level="highestAvailable" " in the manifest file. In the service I call into
LockWorkStation or WTSLogoffSession, which do not seem to be working on
Vista. GetLastError to both the functions returns error code 5.

Is there anything that I need to do.

Please help.

Thanks,
Santosh
 
I have written a service with "requestedExecutionLevel
level="highestAvailable" " in the manifest file. In the service I call into
LockWorkStation or WTSLogoffSession, which do not seem to be working on
Vista. GetLastError to both the functions returns error code 5.

It sounds like your Service is attempting to perform these actions (lock
workstation, logout) for the interactive user, right?

In Windows Vista and higher, Services do not run in the same Session as
the logged-in user. Services run in Session 0; and users are in
Sesssions 1, 2 3 and so on. So your Service cannot just cross session
boundaries and log off a user in another session - that would be a
security violation. Hence the Access Denied error.

Start by reading this paper, and then redesign your Service accordingly:

http://www.microsoft.com/whdc/system/sysinternals/Session0Changes.mspx

It may require more that just changing one or two lines of code; you may
need to re-architect the whole thing.

A few other references:

http://windowsteamblog.com/blogs/developers/archive/2009/10/01/session-0-isolation.aspx

http://msdn.microsoft.com/en-us/library/bb756986.aspx

http://channel9.msdn.com/posts/Char...Services-running-as-Interactive-with-Desktop/

Hope it helps,

Andrew
 
Back
Top