sanfilip / cassia Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/cassia
Automatically exported from code.google.com/p/cassia
Welcome to Cassia, a .NET Terminal Services library. For the latest information, visit the project website: http://cassia.googlecode.com/ GETTING STARTED You'll find the main Cassia assembly in the Bin folder and API documentation in the Doc folder. SAMPLES To build and run the sample console application, open the Cassia.sln solution file. FEEDBACK Post your questions to the Cassia mailing list at [email protected]. Bugs and feature requests can be submitted using the Issues tab on the project website.
Often it's +7 minutes. Not sure where this value comes from.
Original issue reported on code.google.com by danports
on 4 Jun 2009 at 2:30
WTS_INFO_CLASS.WTSWorkingDirectory and WTSInitialProgram
Original issue reported on code.google.com by danports
on 10 May 2009 at 2:03
New feature.
Provide support for call back functions for session events: connect,
disconnect, go into idle, resume from idle,...).
Original issue reported on code.google.com by [email protected]
on 11 Feb 2012 at 6:21
TLSConnectToLsServer, etc.
Create ITerminalServicesLicenseServer or similar.
Original issue reported on code.google.com by danports
on 10 May 2009 at 1:42
Right now it only reports time without user input.
Original issue reported on code.google.com by danports
on 10 May 2009 at 1:50
Not sure if this does anything different than logging off a session.
Original issue reported on code.google.com by danports
on 17 Nov 2009 at 2:56
WTSQueryUserConfig, WTSSetUserConfig.
Original issue reported on code.google.com by danports
on 10 May 2009 at 1:32
I'm getting this error when I try to enumerate sessions on 2003 server.
The remote server is not under any heavy load.
Exception calling "GetSessions" with "0" argument(s): "Not a valid Win32
FileTime. Parameter name: fileTime"
It happens many times and I need to close the connection and connect
again, which doesn't always resolves the problem.
Original issue reported on code.google.com by [email protected]
on 31 Jan 2010 at 7:12
WTSRegisterSessionNotification(Ex)
Original issue reported on code.google.com by danports
on 10 May 2009 at 1:34
WTSStartRemoteControlSession, etc.
Would need to use undocumented functions for < Windows Server 2008.
Original issue reported on code.google.com by danports
on 10 May 2009 at 1:36
What steps will reproduce the problem?
Is not a problem, the library is great (saved a lot of time for me), it's
an enhancement request:
Get the public IP of the network the user is connected from.
What is the expected output?
Something like this:
session.ClientIPAddress: 192.168.0.47 (already implemented)
session.NetworkIPAddress: 85.204.102.165 (enhancement request)
What version of the product are you using? On what operating system?
Version 2.0.0.60 on Windows Server 2008
Please provide any additional information below.
No additional information, just want to say congratulations for your work !
Original issue reported on code.google.com by [email protected]
on 17 Nov 2009 at 11:42
Need to add IPv6 support in a couple of places in TerminalServicesSession.
Original issue reported on code.google.com by danports
on 11 May 2009 at 1:37
For example:
http://www.pinvoke.net/default.aspx/wtsapi32.WTSEnumerateSessions
Original issue reported on code.google.com by danports
on 13 May 2009 at 2:46
Perhaps CodeBetter would be willing to host the project CI.
http://codebetter.com/blogs/james.kovacs/archive/2009/02/24/announcing-
teamcity-codebetter-com.aspx
Original issue reported on code.google.com by danports
on 15 Oct 2009 at 5:28
- EncryptionLevel
- OutBufCountHost, OutBufCountClient, OutBufLength (not sure what these would
be useful for)
- DeviceId
Original issue reported on code.google.com by danports
on 15 Feb 2012 at 2:59
Hi,
I think there is a memory leak, but I couldn't figure out where is it.
if I call the following function several times, with some delay of 20 sec, then
I can see that my program memory is going up and up:
public static IList<ITerminalServicesSession> GetMachinesSessions(string
machineName)
{
ITerminalServicesManager manager = new TerminalServicesManager();
using (ITerminalServer server = manager.GetRemoteServer(machineName))
{
server.Open();
return server.GetSessions();
}
}
So do you think that maybe there is some memory leak?
Thanks,
Tomer
Original issue reported on code.google.com by [email protected]
on 9 Mar 2011 at 9:51
Bytes transferred, number of frames, etc.
WTSINFO has this information on >= Windows Server 2008.
Original issue reported on code.google.com by danports
on 10 May 2009 at 1:53
Run some programs that put the Terminal Server service under load, like a
loop that constantly prints the number of sessions on the server. You
eventually get an exception like this (v1 stack trace; v2 is similar):
Not a valid Win32 FileTime.
Parameter name: fileTime
at System.DateTime.FromFileTimeUtc(Int64 fileTime)
at System.DateTime.FromFileTime(Int64 fileTime)
at Cassia.TerminalServicesManager.FileTimeToDateTime(FILETIME ft) in
c:\Projects\Cassia\Source\Cassia\TerminalServicesManager.cs:line 87
at Cassia.TerminalServicesManager.GetSessionInfo(IntPtr server, UInt32
sessionId) in
c:\Projects\Cassia\Source\Cassia\TerminalServicesManager.cs:line 152
at Cassia.TerminalServicesManager.GetSessions(String serverName) in
c:\Projects\Cassia\Source\Cassia\TerminalServicesManager.cs:line 60
The error is reported while fetching session 2 of 3 (either the listening
session or the console session, probably).
Original issue reported on code.google.com by danports
on 4 Aug 2009 at 1:00
Hi there,
I am using CASSIA 2.0.0.60 on windows server 2003 in vb.net
As per issue 20 (sorry if I am repeating) I am looking to logoff users
after 30 minutes of idle time however I have noticed (not always, just
sometimes) my idletime / lastlogintimes are +7 minutes out?
Is there a manual fix I need to apply?
P.s GREAT job on this project - could not have completed my first project
without this!
Original issue reported on code.google.com by [email protected]
on 15 Oct 2009 at 4:32
What steps will reproduce the problem?
1. Dim session As ITerminalServicesSession = server.GetRemoteServer
("server-name")
I have a couple of terminal servers but on a different network connected
via VPN. When I try to query them and open the connection I get "access
denied" Is there a way to pass user/name password parameters?
What is the expected output? What do you see instead?
"Access-denied"
What version of the product are you using? On what operating system?
Latest version of your Libarary. I am building this in VB.net 2008
Please provide any additional information below.
Your library is really helpful and I'm building a program around it to
help me do day to day tasks.
Original issue reported on code.google.com by [email protected]
on 29 Jan 2010 at 5:16
What steps will reproduce the problem?
1.GetSessions()
What is the expected output? What do you see instead?
The usernames that are connected to the terminal server( the sessions). Instead
i get access denied. I have enabled RPC connections on both server and client
PC. still get access denied issue.
What version of the product are you using? On what operating system?
The Latest version. Running software on Windows 7, Terminal Server is 2008 R2
Enterprise
Please provide any additional information below.
Here is my code.
Imports Cassia
Imports System
Imports System.Security.Principal
Imports System.Web
Imports System.Net.Security
Imports System.Runtime
Imports System.Runtime.InteropServices
Imports System.ComponentModel
Public Class Main
Dim LOGON32_LOGON_INTERACTIVE As Integer = 2
Dim LOGON32_PROVIDER_DEFAULT As Integer = 0
Dim impersonationContext As WindowsImpersonationContext
Declare Function LogonUserA Lib "advapi32.dll" (ByVal lpszUsername As String, _
ByVal lpszDomain As String, _
ByVal lpszPassword As String, _
ByVal dwLogonType As Integer, _
ByVal dwLogonProvider As Integer, _
ByRef phToken As IntPtr) As Integer
Declare Auto Function DuplicateToken Lib "advapi32.dll" ( _
ByVal ExistingTokenHandle As IntPtr, _
ByVal ImpersonationLevel As Integer, _
ByRef DuplicateTokenHandle As IntPtr) As Integer
Declare Auto Function RevertToSelf Lib "advapi32.dll" () As Long
Declare Auto Function CloseHandle Lib "kernel32.dll" (ByVal handle As IntPtr) As Long
Public Function RunAsAdmin() As String
impersonateValidUser(tbusername.Text, tbdomain.Text, tbpassword.Text)
End Function
Public Function RunAsUser()
undoImpersonation()
End Function
Private Function impersonateValidUser(ByVal userName As String, _
ByVal domain As String, ByVal password As String) As Boolean
Dim tempWindowsIdentity As WindowsIdentity
Dim token As IntPtr = IntPtr.Zero
Dim tokenDuplicate As IntPtr = IntPtr.Zero
impersonateValidUser = False
If RevertToSelf() Then
If LogonUserA(userName, domain, password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, token) <> 0 Then
If DuplicateToken(token, 2, tokenDuplicate) <> 0 Then
tempWindowsIdentity = New WindowsIdentity(tokenDuplicate)
impersonationContext = tempWindowsIdentity.Impersonate()
If Not impersonationContext Is Nothing Then
impersonateValidUser = True
End If
End If
End If
End If
If Not tokenDuplicate.Equals(IntPtr.Zero) Then
CloseHandle(tokenDuplicate)
End If
If Not token.Equals(IntPtr.Zero) Then
CloseHandle(token)
End If
End Function
Private Sub undoImpersonation()
impersonationContext.Undo()
End Sub
Private Sub Main_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
tbdomain.Text = My.Settings.Domain
tbserver.Text = My.Settings.Server
tbusername.Text = My.Settings.Username
tbpassword.Text = My.Settings.Password
tbFirstRun.Text = My.Settings.FirstRun
If tbFirstRun.Text = "1" Then
FirstRunSetup.Show()
End If
End Sub
Private Sub Main_FormClosing(sender As System.Object, e As System.EventArgs) Handles MyBase.FormClosing
My.Settings.Domain = tbdomain.Text
My.Settings.Server = tbserver.Text
My.Settings.Username = tbusername.Text
My.Settings.Password = tbpassword.Text
My.Settings.FirstRun = tbFirstRun.Text
undoImpersonation()
End Sub
Private Sub btnreset_Click(sender As System.Object, e As System.EventArgs) Handles btnreset.Click
Dim ser As String = tbserver.Text
RunAsAdmin()
Dim manager As ITerminalServicesManager = New TerminalServicesManager()
Using server As ITerminalServer = manager.GetRemoteServer(ser)
server.Open()
For Each session As ITerminalServicesSession In server.GetSessions()
Dim SelectedItems As ListView.SelectedListViewItemCollection = _
CType(sender, ListView).SelectedItems
If (SelectedItems.Count > 0) Then
If session.UserName = SelectedItems(0).SubItems(0).Text Then
manager.CurrentSession.Disconnect()
End If
End If
Next
End Using
End Sub
Private Sub btnconnect_Click(sender As System.Object, e As System.EventArgs) Handles btnconnect.Click
Dim mgr As Cassia.ITerminalServicesManager = New Cassia.TerminalServicesManager()
Dim serverAddr As String = tbserver.Text
Dim serverDomain As String = tbdomain.Text
Dim serverUsername As String = tbusername.Text
Dim serverPassword As String = tbpassword.Text
Using serverInstance = mgr.GetRemoteServer(serverAddr)
serverInstance.Open()
MsgBox(serverInstance.ServerName.ToString)
For Each sessions As ITerminalServicesSession In serverInstance.GetSessions()
If (sessions.ConnectionState = ConnectionState.Disconnected) OrElse (sessions.ConnectionState = ConnectionState.Active) AndAlso (sessions.IdleTime > TimeSpan.FromMinutes(1)) Then
Dim SubItems(4) As String
SubItems(0) = sessions.UserName
SubItems(1) = sessions.ClientName
SubItems(2) = sessions.CurrentTime
SubItems(3) = sessions.ConnectionState
lvusers.Items.Add(New ListViewItem(SubItems))
serverInstance.Close()
End If
Next
End Using
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
FirstRunSetup.Show()
End Sub
End Class
Any help would be much appreciated.
Cheers
Chris
Original issue reported on code.google.com by [email protected]
on 5 Nov 2011 at 2:47
WTS_INFO_CLASS.WTSClientProductId
Original issue reported on code.google.com by danports
on 10 May 2009 at 2:01
WTS_INFO_CLASS.WTSClientHardwareId
Original issue reported on code.google.com by danports
on 10 May 2009 at 2:00
What steps will reproduce the problem?
1. Terminal server has a session in the Down state, typically due to a
hung user process or a hung thread in csrss.exe
2.Call the GetSessions method of an ITerminalServer object
What is the expected output? What do you see instead?
Sessions should be enumerated; a Win32 Exception occurs with the message
'A close operation is pending on the session'
What version of the product are you using? On what operating system?
Version 2.0.0.60 on Windows Server 2003 SP2 (both 32 and 64bit)
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 27 May 2010 at 10:12
What steps will reproduce the problem?
1. Creation of a TerminalServicesSession class
What is the expected output? What do you see instead?
The QuerySessionInformationForStruct returns Success but it fails retrieving
the WTSSessionInfo informations, because the value is not supported. (ref:
http://msdn.microsoft.com/en-us/library/aa383861%28v=vs.85%29.aspx)
What version of the product are you using? On what operating system?
Version 2.0.0.60, Windows Vista 6.0.6000, without Service Pack 1.
Please provide any additional information below.
I think it can be fixed restricting the usage of
QuerySessionInformationForStruct call with OS Version(6,0,6001) instead of OS
Version(6,0) (line 54 on TerminalServicesSession.cs).
Original issue reported on code.google.com by [email protected]
on 1 Sep 2011 at 11:04
WTSVirtualChannelOpen, etc.
Original issue reported on code.google.com by danports
on 10 May 2009 at 1:54
I'm using the TimeSpan IdleTime.TotalMinutes to get remote servers sessions
idle times.
1. on any version of server 2008 x64 the reported idle time is adding 4.31
seconds to the actual idle time.
for example: if the actual idle time is 0, the reported idle time using
IdleTime.TotalMinutes is 4.31.
2. no problem with server 2003.
3. I didn't test on server 2008 x86 platform.
4. the test was made from Windows 7 x64 using Cassia version 2.0.0.60.
5. no problem when running the solution locally on the remote server.
Original issue reported on code.google.com by [email protected]
on 13 Apr 2011 at 2:36
Not sure if this affects v2.0. Seems to happen in the
ServiceBase.SessionChange event handler. Haven't noticed this issue with
web apps.
Original issue reported on code.google.com by danports
on 4 Jun 2009 at 2:31
Hi There.
I have a need to be able to see on which address the client connected to the
RDP server. Eg. If the client was using the IP-address or using dns. Is it
possible using Cassia, to get this information, to get the serveraddress which
the client used to establish the connection?
Been browsing a bit on my own, but couldn’t really find a structure
In which this information should be found.
Hope I make myself clear in this matter.
Help would be very much appreciated.
Original issue reported on code.google.com by [email protected]
on 11 Apr 2011 at 8:15
hi i want to use this code the get all terminal servers.
i want to use this code in asp.net.
foreach (ITerminalServer server in _manager.GetServers(null))
{
//
}
at the function GetServers i recieved the exeption wrong domain format. i have
the same problme when i give the domainname theis function.
i use the cassia verasion 2.0.0.60
the as.net app run as a local administrator account
Original issue reported on code.google.com by [email protected]
on 16 Jul 2011 at 12:18
WTSConnectSession; requires >= Windows Server 2008
Original issue reported on code.google.com by danports
on 10 May 2009 at 1:48
I have tried Cassia, now want to take screen shot of users screen so how can I
do that ?
Thanks
Laxmilal
Original issue reported on code.google.com by [email protected]
on 20 Dec 2010 at 1:28
According to http://www.remkoweijnen.nl/blog/2007/10/20/how-to-launch-a-
process-in-a-terminal-session/, the console session is always session 0 on
Windows 2000.
Original issue reported on code.google.com by danports
on 7 Dec 2009 at 10:52
ITerminalServicesSession.ClientIPAddress should be able to return an IPAddress
when the underlying WinAPI function returns an IPv6 address.
Given that the IN6_ADDR structure via
http://msdn.microsoft.com/en-us/library/ff554787%28v=VS.85%29.aspx is just a
16-byte array, you can see that it's a simple modification. I believe this code
would be sufficient to support this scenario and it works in my limited test
case. (source: Impl\TerminalServicesSession.cs, function GetClientIPAddress,
where the TODO comment is for this issue)
if (addressFamily == AddressFamily.InterNetwork)
{
byte[] address = new byte[4];
Array.Copy(clientAddress.Address, 2, address, 0, 4);
return new IPAddress(address);
} else if(addressFamily == AddressFamily.InterNetworkV6) {
byte[] address = new byte[16];
Array.Copy(clientAddress.Address, 2, address, 0, 16);
return new IPAddress(address);
}
Original issue reported on code.google.com by [email protected]
on 20 Dec 2010 at 11:47
WTS_INFO_CLASS.WTSApplicationName
Original issue reported on code.google.com by danports
on 11 May 2009 at 1:33
1. Worked fine in development
2. Production server on windows 2008 threw an exception on
manager.GetRemoteServer(_serverName). There is no way to send crendentials.
at Cassia.Impl.NativeMethodsHelper.GetSessionInfos
(ITerminalServerHandle server)\r\n at
Cassia.Impl.TerminalServer.GetSessions()\r\n at
mw.Operations.Plugin.Editorial.FilingDocumentControl.GetActiveSessionInfo()
\r\n at
mw.Operations.Plugin.Editorial.FilingDocumentControl.InvokeRemoteConnection
()\r\n at
mw.Operations.Plugin.Editorial.FilingDocumentControl.OpenDocument()\r\n
at mw.Operations.Plugin.Editorial.ReleaseForm.Open(String releaseID,
String sourceID, String regionId, String officeId, String contentTypeId,
String customerId, String releaseCode, String company, String
grdJobStatus, String languageCode, String language, String loginName)
\r\n at mw.Operations.Plugin.Editorial.EditorialControl.OpenRelease
(String ReleaseID, String SourceID, String regionId, String officeId,
String contentTypeId, String customerId, String releaseTypeId, String
Company, String grdJobStatus, String languageCode, String language)\r\n
at mw.Operations.Plugin.Editorial.EditorialControl.OpenSelectedRelease()
\r\n at mw.Operations.Plugin.Editorial.EditorialControl.mnuOpen_Click
(Object sender, EventArgs e)\r\n at Telerik.WinControls.RadItem.OnClick
(EventArgs e)\r\n at Telerik.WinControls.UI.RadButtonItem.OnClick
(EventArgs e)\r\n at Telerik.WinControls.UI.RadMenuItem.OnClick
(EventArgs e)\r\n at Telerik.WinControls.RadItem.DoClick(EventArgs e)
\r\n at Telerik.WinControls.RadItem.PerformClick()\r\n at
Telerik.WinControls.UI.RadDropDownMenu.OnMouseClick(MouseEventArgs e)
\r\n at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)\r\n at System.Windows.Forms.Control.WndProc
(Message& m)\r\n at Telerik.WinControls.RadControl.WndProc(Message& m)
\r\n at Telerik.WinControls.UI.RadPopupControlBase.WndProc(Message& m)
\r\n at System.Windows.Forms.Control.ControlNativeWindow.WndProc
(Message& m)\r\n at System.Windows.Forms.NativeWindow.Callback(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)"
Original issue reported on code.google.com by [email protected]
on 17 Mar 2010 at 10:17
Perhaps have a helper method like session.StartProcess(...).
Original issue reported on code.google.com by danports
on 20 Dec 2010 at 2:22
What steps will reproduce the problem?
1.Connect to a server
2.use ITerminalServicesSession.MessageBox(string text)
or
2. use ITerminalServicesSession.MessageBox(string text, string caption) and
have caption = to "" or null;
What is the expected output? What do you see instead?
Received a error code of -2147467259 ("The stub received bad data") from
line 132 in NativeMethodsHelper.cs
What version of the product are you using? On what operating system?
Cassia 2.0.50727.1433 Server is Server 2003 x64
Can replicate issue by using the send message feature in task manager on
the server, this issue appears to be a windows issue not a cassia issue.
Attached is a edited version of the source to correct issue. uses " "
instead of "" for a null title, also checks for empty titles.
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 5 May 2010 at 7:54
Attachments:
This is because if you try to get information about that session after
calling the async version, you get a nice Win32Exception ("a close
operation is pending...").
Original issue reported on code.google.com by danports
on 29 May 2009 at 5:46
WTS_INFO_CLASS.WTSClientProtocolType
Original issue reported on code.google.com by danports
on 10 May 2009 at 2:02
What steps will reproduce the problem?
1.Running The program
2.Server.open() // Throws Error
3.
What is the expected output? What do you see instead?
It Should Connect To Remote Pc cause i am having admin privilage on remote
pc and my pc both but when it goes to server.open() it throws this error
What version of the product are you using? On what operating system?
Windows XP and 2.0.0.6.0
Please provide any additional information below.
I dont have terminal service manager so is this the reason of error! well
i can connect to remote pc through mstsc without any issue
Any Help Would be appreciated
Thanks in Advance and For Nice Work you have done!
Original issue reported on code.google.com by [email protected]
on 11 Aug 2009 at 3:56
Instead of throwing a generic Win32Exception, provide a bit more information
about possible troubleshooting steps.
Original issue reported on code.google.com by danports
on 20 Oct 2009 at 11:04
WTS_INFO_CLASS.WTSClientDirectory
Original issue reported on code.google.com by danports
on 10 May 2009 at 1:59
This can cause exceptions to be thrown in rare circumstances, e.g. if the
session is going down because the user is logging off.
Original issue reported on code.google.com by danports
on 7 Aug 2009 at 12:43
Remote IP address and port. (IPEndPoint class)
Original issue reported on code.google.com by danports
on 10 May 2009 at 2:04
Packaging kindly provided by Matthew Ferreira.
Original issue reported on code.google.com by danports
on 13 May 2011 at 2:16
Attachments:
Seems like a rather obvious property, if you ask me. Not sure how this differs
from checking WTS_INFO_CLASS.WTSClientProtocolType.
Original issue reported on code.google.com by danports
on 15 Feb 2012 at 3:03
WTSGetActiveConsoleSessionId - requires >= WinXP
Original issue reported on code.google.com by danports
on 10 May 2009 at 1:38
Used in VDI scenarios.
Original issue reported on code.google.com by danports
on 15 Feb 2012 at 3:01
Not sure about remote sessions.
Original issue reported on code.google.com by danports
on 7 Aug 2009 at 12:40
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.