Problem using WTSOpenServer on Win2003Server DC

  • Thread starter Christopher Attard
  • 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
 
M

Mattias Sjögren

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
 
W

Willy Denoyette [MVP]

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
 
C

Christopher Attard

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.
 
W

Willy Denoyette [MVP]

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

Willy.
 
C

Christopher Attard

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

Chris
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top