Is user an administrator

  • Thread starter Thread starter Jack Russell
  • Start date Start date
J

Jack Russell

Is there an easy way to tell if the current user is an administrator?

Thanks
 
well maybe this is an easier to understand example :-)


Dim ident As System.Security.Principal.WindowsIdentity =
System.Security.Principal.WindowsIdentity.GetCurrent()

Dim user As New System.Security.Principal.WindowsPrincipal(ident)

If Not (user.IsInRole(Security.Principal.WindowsBuiltInRole.Administrator))
Then

Me.Visible = False

MsgBox("Settings form only availlable for Administrators ! ",
MsgBoxStyle.DefaultButton3)

Me.Close()

End If




Michel Posseth [MCP]
 
Jack Russell said:
Is there an easy way to tell if the current user is an administrator?

\\\
Imports System.Security.Principal
..
..
..
Dim wp As New WindowsPrincipal(WindowsIdentity.GetCurrent())
Dim IsAdmin As Boolean = wp.IsInRole(WindowsBuiltInRole.Administrator)
///
 
m.posseth said:
well maybe this is an easier to understand example :-)


Dim ident As System.Security.Principal.WindowsIdentity =
System.Security.Principal.WindowsIdentity.GetCurrent()

Dim user As New System.Security.Principal.WindowsPrincipal(ident)

If Not (user.IsInRole(Security.Principal.WindowsBuiltInRole.Administrator))
Then

Me.Visible = False

MsgBox("Settings form only availlable for Administrators ! ",
MsgBoxStyle.DefaultButton3)

Me.Close()

End If




Michel Posseth [MCP]


thanks, I think it does but life would be much easier if someone at MS
spoke English!
Thanks, i wish I had that before I tried to interpret Ms jumble!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top