locked
Getting User Logged In in windows RRS feed

  • Question

  • Hi folks,

    I have some sort of problem, is there anyway to get the Windows Logged In username?

    Thanks in advance

    Tuesday, March 18, 2014 5:35 AM

Answers

  • What logged you wanted to get? the current? or every Users logged in? Pls. specify

    • Marked as answer by brunettecoder Tuesday, March 18, 2014 5:41 AM
    Tuesday, March 18, 2014 5:36 AM
  • Try this code,

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    
        Dim win As System.Security.Principal.WindowsIdentity
            win = System.Security.Principal.WindowsIdentity.GetCurrent
        Dim username = win.Name.Substring(win.Name.IndexOf("\") + 1)
        MessageBox.Show(username)
    
    End Sub

    • Marked as answer by brunettecoder Tuesday, March 18, 2014 5:41 AM
    Tuesday, March 18, 2014 5:41 AM

All replies

  • What logged you wanted to get? the current? or every Users logged in? Pls. specify

    • Marked as answer by brunettecoder Tuesday, March 18, 2014 5:41 AM
    Tuesday, March 18, 2014 5:36 AM
  • Hi Har Das,

    Sorry for insufficient questions, im looking for the current logged, thanks

    Tuesday, March 18, 2014 5:38 AM
  • Try this code,

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    
        Dim win As System.Security.Principal.WindowsIdentity
            win = System.Security.Principal.WindowsIdentity.GetCurrent
        Dim username = win.Name.Substring(win.Name.IndexOf("\") + 1)
        MessageBox.Show(username)
    
    End Sub

    • Marked as answer by brunettecoder Tuesday, March 18, 2014 5:41 AM
    Tuesday, March 18, 2014 5:41 AM