Saturday, 14 January 2012

To check the current account is Administrator or not


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label1.Text = isAdministrator()
    End Sub

Public Function isAdministrator() As Boolean
        ' Check if the user is authenticated.
        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 not authenticated.
        Return False
    End Function

No comments:

Post a Comment