CD-PC Website VB.NET Code Samples


In the future you'll find more examples of code that I have gathered.

getAccountType
Gets the account type/level in wich the program is executed.

The next example is a console application

Module Module1
Sub Main()
	 My.User.InitializeWithWindowsUser()

	 If Not My.User.IsAuthenticated Then
		 Console.WriteLine("Not Authenticated")
	 Console.ReadLine()
		 Exit Sub
	 End If
	 If My.User.IsInRole(ApplicationServices.BuiltInRole.AccountOperator) Then
		 Console.WriteLine("User is " & ApplicationServices.BuiltInRole.AccountOperator.ToString())
	 ElseIf My.User.IsInRole(ApplicationServices.BuiltInRole.Administrator) Then
		 Console.WriteLine("User is " & ApplicationServices.BuiltInRole.Administrator.ToString())
	 ElseIf My.User.IsInRole(ApplicationServices.BuiltInRole.BackupOperator) Then
		 Console.WriteLine("User is " & ApplicationServices.BuiltInRole.BackupOperator.ToString())
	 ElseIf My.User.IsInRole(ApplicationServices.BuiltInRole.User) Then
		 Console.WriteLine("User is " & ApplicationServices.BuiltInRole.User.ToString())
	 ElseIf My.User.IsInRole(ApplicationServices.BuiltInRole.PowerUser) Then
		 Console.WriteLine("User is " & ApplicationServices.BuiltInRole.PowerUser.ToString())
	 ElseIf My.User.IsInRole(ApplicationServices.BuiltInRole.PrintOperator) Then
		 Console.WriteLine("User is " & ApplicationServices.BuiltInRole.PrintOperator.ToString())
	 ElseIf My.User.IsInRole(ApplicationServices.BuiltInRole.Replicator) Then
		 Console.WriteLine("User is " & ApplicationServices.BuiltInRole.Replicator.ToString())
	 ElseIf My.User.IsInRole(ApplicationServices.BuiltInRole.SystemOperator) Then
		 Console.WriteLine("User is " & ApplicationServices.BuiltInRole.SystemOperator.ToString())
	 Else
		 Console.WriteLine("User is " & ApplicationServices.BuiltInRole.Guest.ToString())
	 End If
	 Console.ReadLine()
End Sub
End Module
Download
https://cd-pc.be/downloads/sourcecode/getAccountType.zip