Hi Deti,
Please try the following sample code:
Imports System.Security.Principal
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim wi As WindowsIdentity = WindowsIdentity.GetCurrent()
Dim wp As New WindowsPrincipal(wi)
Dim result As Boolean = wp.IsInRole(WindowsBuiltInRole.Administrator)
If result then
MessageBox.Show("The current user is anAdmin.")
else
MessageBox.Show("The current useris not an Admin.")
End If
End Sub
End Class
In addition, if you run this code on Windows Vista, you need to run the application as Administrator so that the result variable returns true.
Hope thishelps.
If you have any question, please feel free to let me know.
Sincerely,
Linda Liu
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.