Problem using WTSOpenServer on Win2003Server DC

  • Thread starter Thread starter Christopher Attard
  • Start date Start date
C

Christopher Attard

Hi,
I'm using WTSOpenServer (P/Invoke in a C# application) to open a
handle to a specified terminal server which is Win2003 Server Domain
Controller.

The function is returning NULL (or 0). I'm able to connect
successfully to the terminal server when using the remote desktop program
from a WinXP client machine.

Any ideas or suggestions pls?

Regards,
Chris Attard
 
Any ideas or suggestions pls?

Ensure that you have SetLastError=true in your DllImport attribute,
then call Marshal.GetLastWin32Error() after the call to
WTSOpenServer() to get an idea about why its failing.



Mattias
 
Which means "access denied".
You have to impersonate using a privileged account's credentials (like a
domain admins, or enterprise admins account).

Willy.


Christopher Attard said:
Yes, I'm already dong it....The error returned is: 5
 
I'm using the Administrator account which is a member of the Domain Admins
and still it's returning an error of 5. What seems awkward is that when I'm
using the same account to connect to the same server through mstsc.exe, its
creating a successful terminal session.

Chris

Willy Denoyette said:
Which means "access denied".
You have to impersonate using a privileged account's credentials (like a
domain admins, or enterprise admins account).

Willy.
 
Should work, try using a DC administrator account.
- check the eventlog (turn on auditing).
- check your accounts privileges.

Willy.
 
Thanks Willy...problem solved. Infact i was running the call in the security
context of a non-administrative account.

Chris
 
Back
Top