Example #1
0
        public static Luid[] GetLogonSessions()
        {
            NtStatus status;
            int      logonSessionCount;
            IntPtr   logonSessionList;

            if ((status = Win32.LsaEnumerateLogonSessions(
                     out logonSessionCount,
                     out logonSessionList
                     )) >= NtStatus.Error)
            {
                Win32.Throw(status);
            }

            Luid[] logonSessions = new Luid[logonSessionCount];

            using (var logonSessionListAlloc = new LsaMemoryAlloc(logonSessionList, true))
            {
                for (int i = 0; i < logonSessionCount; i++)
                {
                    logonSessions[i] = logonSessionListAlloc.ReadStruct <Luid>(i);
                }

                return(logonSessions);
            }
        }
Example #2
0
        public static SystemLogonSession GetLogonSession(Luid logonId)
        {
            NtStatus status;
            IntPtr   logonSessionData;

            if ((status = Win32.LsaGetLogonSessionData(
                     ref logonId,
                     out logonSessionData
                     )) >= NtStatus.Error)
            {
                Win32.Throw(status);
            }

            using (var logonSessionDataAlloc = new LsaMemoryAlloc(logonSessionData, true))
            {
                var info = logonSessionDataAlloc.ReadStruct <SecurityLogonSessionData>();

                return(new SystemLogonSession(
                           info.AuthenticationPackage.Read(),
                           info.DnsDomainName.Read(),
                           info.LogonDomain.Read(),
                           info.LogonId,
                           info.LogonServer.Read(),
                           DateTime.FromFileTime(info.LogonTime),
                           info.LogonType,
                           info.Session,
                           new Sid(info.Sid),
                           info.Upn.Read(),
                           info.UserName.Read()
                           ));
            }
        }
Example #3
0
        public static SystemLogonSession GetLogonSession(Luid logonId)
        {
            IntPtr logonSessionData;

            Win32.LsaGetLogonSessionData(
                ref logonId,
                out logonSessionData
                ).ThrowIf();

            using (var logonSessionDataAlloc = new LsaMemoryAlloc(logonSessionData, true))
            {
                var info = logonSessionDataAlloc.ReadStruct <SecurityLogonSessionData>();

                return(new SystemLogonSession(
                           info.AuthenticationPackage.Text,
                           info.DnsDomainName.Text,
                           info.LogonDomain.Text,
                           info.LogonId,
                           info.LogonServer.Text,
                           DateTime.FromFileTime(info.LogonTime),
                           info.LogonType,
                           info.Session,
                           new Sid(info.Sid),
                           info.Upn.Text,
                           info.UserName.Text
                           ));
            }
        }
Example #4
0
        public static Luid[] GetLogonSessions()
        {
            int    logonSessionCount;
            IntPtr logonSessionList;

            Win32.LsaEnumerateLogonSessions(
                out logonSessionCount,
                out logonSessionList
                ).ThrowIf();

            Luid[] logonSessions = new Luid[logonSessionCount];

            using (LsaMemoryAlloc logonSessionListAlloc = new LsaMemoryAlloc(logonSessionList, true))
            {
                for (int i = 0; i < logonSessionCount; i++)
                {
                    logonSessions[i] = logonSessionListAlloc.ReadStruct <Luid>(0, Luid.SizeOf, i);
                }

                return(logonSessions);
            }
        }
Example #5
0
        public static Luid[] GetLogonSessions()
        {
            int logonSessionCount;
            IntPtr logonSessionList;

            Win32.LsaEnumerateLogonSessions(
                out logonSessionCount,
                out logonSessionList
                ).ThrowIf();

            Luid[] logonSessions = new Luid[logonSessionCount];

            using (LsaMemoryAlloc logonSessionListAlloc = new LsaMemoryAlloc(logonSessionList, true))
            {
                for (int i = 0; i < logonSessionCount; i++)
                    logonSessions[i] = logonSessionListAlloc.ReadStruct<Luid>(0, Luid.SizeOf, i);

                return logonSessions;
            }
        }
Example #6
0
        public static SystemLogonSession GetLogonSession(Luid logonId)
        {
            IntPtr logonSessionData;

            Win32.LsaGetLogonSessionData(
                ref logonId,
                out logonSessionData
                ).ThrowIf();

            using (var logonSessionDataAlloc = new LsaMemoryAlloc(logonSessionData, true))
            {
                var info = logonSessionDataAlloc.ReadStruct<SecurityLogonSessionData>();

                return new SystemLogonSession(
                    info.AuthenticationPackage.Text,
                    info.DnsDomainName.Text,
                    info.LogonDomain.Text,
                    info.LogonId,
                    info.LogonServer.Text,
                    DateTime.FromFileTime(info.LogonTime),
                    info.LogonType,
                    info.Session,
                    new Sid(info.Sid),
                    info.Upn.Text,
                    info.UserName.Text
                    );
            }
        }
Example #7
0
        public static Luid[] GetLogonSessions()
        {
            NtStatus status;
            int logonSessionCount;
            IntPtr logonSessionList;

            if ((status = Win32.LsaEnumerateLogonSessions(
                out logonSessionCount,
                out logonSessionList
                )) >= NtStatus.Error)
                Win32.ThrowLastError(status);

            Luid[] logonSessions = new Luid[logonSessionCount];

            using (var logonSessionListAlloc = new LsaMemoryAlloc(logonSessionList, true))
            {
                for (int i = 0; i < logonSessionCount; i++)
                    logonSessions[i] = logonSessionListAlloc.ReadStruct<Luid>(i);

                return logonSessions;
            }
        }
Example #8
0
        public static SystemLogonSession GetLogonSession(Luid logonId)
        {
            NtStatus status;
            IntPtr logonSessionData;

            if ((status = Win32.LsaGetLogonSessionData(
                ref logonId,
                out logonSessionData
                )) >= NtStatus.Error)
                Win32.ThrowLastError(status);

            using (var logonSessionDataAlloc = new LsaMemoryAlloc(logonSessionData, true))
            {
                var info = logonSessionDataAlloc.ReadStruct<SecurityLogonSessionData>();

                return new SystemLogonSession(
                    info.AuthenticationPackage.Read(),
                    info.DnsDomainName.Read(),
                    info.LogonDomain.Read(),
                    info.LogonId,
                    info.LogonServer.Read(),
                    DateTime.FromFileTime(info.LogonTime),
                    info.LogonType,
                    info.Session,
                    new Sid(info.Sid),
                    info.Upn.Read(),
                    info.UserName.Read()
                    );
            }
        }