Advertisement
6_2008-2009 Security #214577

User Privileges

This code can check if the user that is logged on to windows is an administrator.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
The following code will check to see if a user is an administrator.

    If My.User.IsInRole(ApplicationServices.BuiltInRole.Administrator) = True Then
      lblResponse.Text = "This user is an administrator."
    Else
      lblResponse.Text = "This user is not an administrator."
    End If
You can change the BuiltInRole.Administrator to one of the following to check for a different user group: -
BuiltInRole.AccountOperator
BuiltInRole.BackupOperator
BuiltInRole.Guest
BuiltInRole.PowerUser
BuiltInRole.PrintOperator
BuiltInRole.Replicator
BuiltInRole.SystemOperator
BuiltInRole.User
This code was tested on Windows Vista, this code should be compatible with Windows 2000/XP/2003 Server
Original Comments (3)
Recovered from Wayback Machine