Check if the user is an administrator
This function will return a boolean result of whether the user is enrolled in the administrators group or not.
VB.NET
''' <summary>
''' Check if the user belongs to the administrators group.
''' </summary>
''' <returns>True if the user belongs to the administrators group.</returns>
''' <remarks></remarks>
Public Function isAdministrator() As Boolean
' Check if the user is authenticated before continuing.
If My.User.IsAuthenticated Then
' If the user is in the administrators group.
If My.User.IsInRole("Administrators") Then
Return True
End If
End If
' Return false because the user isn't an administrator,
' or authenticated.
Return False
End Function
' Example Usage
MessageBox.Show(isAdministrator())
See Also
- </DIC> Submission - http://www.dreamincode.net/code/snippet1558.htm
page_revision: 0, last_edited: 1198651200|%e %b %Y, %H:%M %Z (%O ago)





