IsUserAnAdmin function

Expand
2 out of 7 rated this helpful Rate this topic

IsUserAnAdmin function

Tests whether the current user is a member of the Administrator's group.

Syntax

BOOL IsUserAnAdmin(void);

Parameters

This function has no parameters.

Return value

Type: BOOL

Returns TRUE if the user is a member of the Administrator's group; otherwise, FALSE.

Remarks

This function is a wrapper for CheckTokenMembership. It is recommended to call that function directly to determine Administrator group status rather than calling IsUserAnAdmin.

Note  This function is available through Windows Vista. It might be altered or unavailable in subsequent versions of Windows.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Shlobj.h

Library

Shell32.lib

DLL

Shell32.dll (version 5.0 or later)

See also

CheckTokenMembership

 

 

Send comments about this topic to Microsoft

Build date: 9/7/2011

Did you find this helpful?
(1500 characters remaining)
Community Additions ADD
Not supported on Windows 2000
The minimum supported client is incorrect. There is no DLL entry point for IsUserAnAdmin in Shell32.dll of Windows 2000 Professional (SP4). Not checked on Windows Server 2000, but mostly it wont work either.
11/21/2011
C# syntax
[DllImport("shell32.dll")]
public static extern bool IsUserAnAdmin();

if(IsUserIsAnAdmin()){
MessageBox.Show("User is Admin");
}
else {
MessageBox.Show("Not a Admin");
}
1/27/2011
vb.net syntax
<DllImport("shell32.dll", EntryPoint:="IsUserAnAdmin")> Public Shared Function IsUserAnAdmin() As Boolean
End Function

If IsUserAnAdmin = False Then
MessageBox.Show("Not a Admin")
ElseIf IsUserAnAdmin = True Then
MessageBox.Show("User is Admin")
End If

4/22/2009