473,378 Members | 1,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Problem using WTSOpenServer on Win2003Server DC

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
Nov 16 '05 #1
6 2782
> 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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #2
Yes, I'm already dong it....The error returned is: 5

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:uV**************@TK2MSFTNGP11.phx.gbl...
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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 16 '05 #3
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" <ch*********@gfi.com> wrote in message
news:e3**************@TK2MSFTNGP15.phx.gbl...
Yes, I'm already dong it....The error returned is: 5

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:uV**************@TK2MSFTNGP11.phx.gbl...
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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


Nov 16 '05 #4
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 [MVP]" <wi*************@pandora.be> wrote in message
news:eX**************@tk2msftngp13.phx.gbl...
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" <ch*********@gfi.com> wrote in message
news:e3**************@TK2MSFTNGP15.phx.gbl...
Yes, I'm already dong it....The error returned is: 5

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:uV**************@TK2MSFTNGP11.phx.gbl...
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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.



Nov 16 '05 #5
Should work, try using a DC administrator account.
- check the eventlog (turn on auditing).
- check your accounts privileges.

Willy.

"Christopher Attard" <ch*********@gfi.com> wrote in message
news:ez**************@TK2MSFTNGP15.phx.gbl...
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 [MVP]" <wi*************@pandora.be> wrote in message
news:eX**************@tk2msftngp13.phx.gbl...
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" <ch*********@gfi.com> wrote in message
news:e3**************@TK2MSFTNGP15.phx.gbl...
Yes, I'm already dong it....The error returned is: 5

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:uV**************@TK2MSFTNGP11.phx.gbl...
> 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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.



Nov 16 '05 #6
Thanks Willy...problem solved. Infact i was running the call in the security
context of a non-administrative account.

Chris

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:eS**************@TK2MSFTNGP14.phx.gbl...
Should work, try using a DC administrator account.
- check the eventlog (turn on auditing).
- check your accounts privileges.

Willy.

"Christopher Attard" <ch*********@gfi.com> wrote in message
news:ez**************@TK2MSFTNGP15.phx.gbl...
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 [MVP]" <wi*************@pandora.be> wrote in message
news:eX**************@tk2msftngp13.phx.gbl...
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" <ch*********@gfi.com> wrote in message
news:e3**************@TK2MSFTNGP15.phx.gbl...
Yes, I'm already dong it....The error returned is: 5

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:uV**************@TK2MSFTNGP11.phx.gbl...
>> 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
>
> --
> Mattias Sjögren [MVP] mattias @ mvps.org
> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> Please reply only to the newsgroup.



Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Aaron Prohaska | last post by:
I have just run into a problem where I have a page that posts back to itself to execute code, except when the page does the post back it somehow executes code that is in our home page for the site....
2
by: Moses M | last post by:
I am new to C#! I need to enumerate TS sessions (including sessions running in non-application mode) using a C# application. Can this be done using a "TS-WMI" provider? Any input will be...
9
by: Rajat Tandon | last post by:
Hello there, I am relatively new to the newsgroups and C#. I have never been disappointed with the groups and always got the prompt replies to my queries.This is yet another strange issue, I am...
5
by: IkBenHet | last post by:
Hello, I use this script to upload image files to a folder on a IIS6 server: ******************* START UPLOAD.ASPX FILE ********************** <%@ Page Language="VB" Debug="true" %>
1
by: Nikolay Petrov | last post by:
I use some of Windows Terminal Services APIs in my app. The is an API function which enumerates sessions on a terminal server. It uses a pointer from another API function to know on which...
8
by: Sarah | last post by:
I need to access some data on a server. I can access it directly using UNC (i.e. \\ComputerName\ShareName\Path\FileName) or using a mapped network drive resource (S:\Path\FileName). Here is my...
3
by: Adam | last post by:
This is my first attempt at using the Terminal Services API, and I'm stumped. I can't get WTSOpenServer to work for the life of me (this is in VS2005, by the way). Specifically, the argument has...
0
by: Jason Huang | last post by:
Hi, In my Windows Server 2003 I have installed VS2005, and I have the Visual Studio Remote Debugging Monitor runnig. The Debugging Monitor recorded this line: 3/22/2007 05:37:58PM...
10
by: olafilink | last post by:
Hello, we're running an Win2003server with IIS6 and PHP4 in fastCGI config. When i try to use system() command to execute ffmpeg.exe it works ok when i run the PHP script from the commandline on...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.