Display Windows User Properties in VB.NET

Today, I will teach you how to create a program that displays the Windows User Properties in VB.NET. It will have Windows user properties like Username, Guest User, System, Anonymous, Authentication, Impersonation Level, Authentication Type, Groups, Owner Value, User Value, and Token Size. Now, let's start this tutorial! 1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application. 2. Next, add only one TextBox named TextBox1. 3. Now, we will do the coding. First, import the System.Security library to access the Principal keyword that will be used for accessing the windows identity.
  1. Imports System.Security
Then code for the Form Load. To access the username who logged in your PC. Have this code:
  1. TextBox1.Text = "- Username: " + Principal.WindowsIdentity.GetCurrent.Name
To determine if it is a guest user or not. Have this code:
  1. If Principal.WindowsIdentity.GetCurrent.IsGuest = "false" Then
  2. TextBox1.Text = TextBox1.Text & vbCrLf & "- Not Guest User"
  3. Else
  4. TextBox1.Text = TextBox1.Text & vbCrLf & "- Guest User"
  5. End If
To determine if it is a system user or not. Have this code:
  1. If Principal.WindowsIdentity.GetCurrent.IsSystem = "false" Then
  2. TextBox1.Text = TextBox1.Text & vbCrLf & "- Not System"
  3. Else
  4. TextBox1.Text = TextBox1.Text & vbCrLf & "- System"
  5. End If
To determine if it is an anonymous user or not. Have this code:
  1. If Principal.WindowsIdentity.GetCurrent.IsAnonymous = "false" Then
  2. TextBox1.Text = TextBox1.Text & vbCrLf & "- Not Anonymous"
  3. Else
  4. TextBox1.Text = TextBox1.Text & vbCrLf & "- Anonymous"
  5. End If
To determine if it is an authenticated or not. Have this code:
  1. If Principal.WindowsIdentity.GetCurrent.IsAuthenticated = "false" Then
  2. TextBox1.Text = TextBox1.Text & vbCrLf & "- Not Authenticatedr"
  3. Else
  4. TextBox1.Text = TextBox1.Text & vbCrLf & "- Authenticated"
  5. End If
To determine the Impersonation Level. Have this code:
  1. TextBox1.Text = TextBox1.Text & vbCrLf & "- Impersonation Level: " & Principal.WindowsIdentity.GetCurrent.ImpersonationLevel
To determine the Authentication Type. Have this code:
  1. TextBox1.Text = TextBox1.Text & vbCrLf & "- Authentication Type: " & Principal.WindowsIdentity.GetCurrent.AuthenticationType.ToString
To determine the Groups. Have this code:
  1. TextBox1.Text = TextBox1.Text & vbCrLf & "- Groups: " & Principal.WindowsIdentity.GetCurrent.Groups.ToString
To determine the Owner Value. Have this code:
  1. TextBox1.Text = TextBox1.Text & vbCrLf & "- Owner Value: " & Principal.WindowsIdentity.GetCurrent.Owner.Value.ToString
To determine the User Value. Have this code:
  1. TextBox1.Text = TextBox1.Text & vbCrLf & "- User Value: " & Principal.WindowsIdentity.GetCurrent.User.Value.ToString
To determine the Token Size. Have this code:
  1. TextBox1.Text = TextBox1.Text & vbCrLf & "- Token Size: " & Principal.WindowsIdentity.GetCurrent.Token.Size

Output:

output For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below. Best Regards, Engr. Lyndon Bermoy IT Instructor/System Developer/Android Developer/Freelance Programmer Mobile: 09488225971 Landline: 826-9296 E-mail:[email protected] Add and Follow me on Facebook: https://www.facebook.com/donzzsky Visit and like my page on Facebook at: https://www.facebook.com/BermzISware

Add new comment