Re: Check Current User is a Domaingroup member
From: Eric Marvets (ericm_at_bangproject.com)
Date: 05/23/04
- Previous message: Eric Marvets: "Re: Persist login does not work"
- In reply to: Tim B: "Check Current User is a Domaingroup member"
- Next in thread: Tim B: "Re: Check Current User is a Domaingroup member"
- Reply: Tim B: "Re: Check Current User is a Domaingroup member"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Sun, 23 May 2004 15:34:51 -0400
Here is what you do:
At the start of the application (Shared Sub Main):
Dim ident as WindowsIdentity = WindowsIdentity.GetCurrent()
Dim prin As New WindowsPrincipal(ident)
System.Threading.Thread.CurrentPrincipal = prin
If not prin.IsInRole("dom\role") then
'throw an exception
'shutdown app
end if
'launch main form
End Sub
This also allows you to place attributes on methods to check their security
Level later in the application as well:
<PrincipalPermissionAttribute(SecurityAction.Demand, Role :=
"dom\ProductAdministrator")> Public sub CreateProduct (....)
End Sub
-or-
If
System.Threading.Thread.CurrentPrincipal.IsInRole("dom\ProductAdministrator"
) then CreateProduct(....)
-- Eric Marvets Principal Consultant the bang project <shameless self promotion> Email sales@bangproject.com for Information on Our Architecture and Mentoring Services </shameless self promotion>
- Previous message: Eric Marvets: "Re: Persist login does not work"
- In reply to: Tim B: "Check Current User is a Domaingroup member"
- Next in thread: Tim B: "Re: Check Current User is a Domaingroup member"
- Reply: Tim B: "Re: Check Current User is a Domaingroup member"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]