yalcinkucukoztas / cassia

Automatically exported from code.google.com/p/cassia
0 stars 0 forks source link

Access Denied on if (NativeMethods.WTSEnumerateSessions(server.Handle, 0, 1, out ppSessionInfo, out count) == 0) #58

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. I have impersonate the user code.
2. The error is when the code runs server.GetSessions()

What is the expected result? What happens instead?
Get the connected user instead of Access Denied

What version of Cassia are you using (e.g. 2.0.0.60)?
2.0.0.60

On what Windows version is your code running?
Code run from Windows 7 Enterprise. The connected machine is Windows Server 
2008 R2

Is your code running as a Windows service, an ASP.NET application, or 
standalone application?
a. ASP.NET 4.0

What Windows version is running on the remote server you are trying to
access (if any)?
Code run from Windows 7 Enterprise. The connected machine is Windows Server 
2008 R2

Please provide any additional information below. If you are running into an
exception, please include a stack trace (at least the portion of it that
relates to Cassia).

Line 95:             if (NativeMethods.WTSEnumerateSessions(server.Handle, 0, 
1, out ppSessionInfo, out count) == 0)
Line 96:             {
Line 97:                 throw new Win32Exception();
Line 98:             }
Line 99:             try

[Win32Exception (0x80004005): Access is denied]
   Cassia.Impl.NativeMethodsHelper.GetSessionInfos(ITerminalServerHandle server) in C:\Users\\Desktop\Cassia\Source\Cassia\Impl\NativeMethodsHelper.cs:97
   Cassia.Impl.TerminalServer.GetSessions() in C:\Users\\Desktop\Cassia\Source\Cassia\Impl\TerminalServer.cs:38
   WebApplication1.Cassia.Page_Load(Object sender, EventArgs e) in C:\Users\\Documents\Visual Studio 2010\Projects\RoamingTest\WebApplication1\Cassia.aspx.cs:29
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +91
   System.Web.UI.Control.LoadRecursive() +74
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

Original issue reported on code.google.com by chuan...@gmail.com on 13 Mar 2012 at 8:43

Attachments:

GoogleCodeExporter commented 8 years ago
The problem is likely in the impersonation code or in the Remote Desktop 
permissions you've set on the remote server. How are you impersonating the 
user? If you open a command prompt under that user account on the Windows 7 
machine and run qwinsta /server:whatever, does it work or do you get an access 
denied error?

Original comment by danports on 13 Mar 2012 at 1:18

GoogleCodeExporter commented 8 years ago
Hi, I have tried using the qwinsta and it did give me an access denied error.
The account holder is already a local admin.

Can you please guide me if I have any more rights to be granted?

Thanks.

Original comment by chuan...@gmail.com on 15 Mar 2012 at 7:45

GoogleCodeExporter commented 8 years ago
Are you running qwinsta as an elevated process? The account you're 
impersonating is a local admin on the remote server, right? What happens if you 
run "telnet <server> 445"? Is the RDS Manager able to connect to the server 
when run under the appropriate user account?

Original comment by danports on 15 Mar 2012 at 1:17

GoogleCodeExporter commented 8 years ago
Thanks for the incredible support.
It turns out to be the AllowRemote is not set in registry.

Thanks a million again.

Original comment by chuan...@gmail.com on 4 Apr 2012 at 2:55

GoogleCodeExporter commented 8 years ago
Hm, the AllowRemoteRPC registry key is generally only an issue for client 
versions of Windows, so I didn't mention it since it sounded like you were 
trying to connect to a server version. But I'm glad you found the solution!

Original comment by danports on 5 Apr 2012 at 8:37