Exemple #1
0
        private static string GetDomainName(int sessionId)
        {
            string domainName = "SYSTEM";

            if (WinApiHelper.WTSQuerySessionInformation(IntPtr.Zero, sessionId, WtsInfoClass.WTSDomainName, out IntPtr buffer, out int strLen) && strLen > 1)
            {
                domainName = Marshal.PtrToStringAnsi(buffer);
                WinApiHelper.WTSFreeMemory(buffer);
            }
            return(domainName);
        }
Exemple #2
0
        private void LogoffUser(int sessionId)
        {
            var userName = GetUserName(sessionId);

            if (!string.IsNullOrEmpty(userName))
            {
                if (WinApiHelper.WTSLogoffSession(IntPtr.Zero, sessionId, true))
                {
                    RemoveUser(sessionId);
                }
            }
        }
Exemple #3
0
 private void LockUser()
 {
     WinApiHelper.ExecuteAppAsLoggedOnUser("rundll32.exe user32.dll,LockWorkStation");
 }