Re: Active Directory vs SqlServer which way to go?
From: Jan Peter Stotz (jp_news_at_gmx.de)
Date: 11/04/05
- Previous message: Jan Peter Stotz: "Re: Active Directory vs SqlServer which way to go?"
- Maybe in reply to: Patrick.O.Ige: "Active Directory vs SqlServer which way to go?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Fri, 4 Nov 2005 22:04:35 +0100
Patrick Allmond schrieb:
> Sorry I did not clarify. Specifically I meant how did you get the custom
> control property to work - the one that checks the role before it decides to
> display or not?
Ok, I am not an expert in custom controls, so I post my code (vb.net)
allowing everybody to review it.
I hope the posted code compiles. I had to made some changes with a
texteditor to simplify it and no vb.net compiler at hand for checking, if
it works. My original code uses a separate class called "Authentificator"
that implements my special "isinRole-Check". The posted version can only
check one role, but it is easy to extend it to accept a somehow separated
list (e.g. semicolon) of roles that will be checked.
Namespace MyWebControls
Public Class SecurityButton : Inherits Button
Private _RequiredRole as String
Public Property RequiredRole As String
Get
return _RequiredRole
End Get
Set
_RequiredRole = Value
End Set
End Property
Protected Overrides Sub Render(Output As HtmlTextWriter)
Dim p As Principal = HttpContext.Current.User
If p.isInRole(_RequiredRole) Then
MyBase.Render(Output)
End If
End Sub
Protected Overrides Sub OnCommand(ByVal e As CommandEventArgs)
Dim p As Principal = HttpContext.Current.User
If p.isInRole(_RequiredRole) Then
MyBase.OnCommand(e)
End If
End Sub
End Class
End Namespace
test.aspx:
<%@ Page Language="VB" %>
<%@ Register TagPrefix="asps" Namespace="MyWebControls"
Assembly="MyWebControls" %>
[..]
<asps:SecurityButton RequiredRole="DOMAIN\Groupname" id="mySecurityButton"
runat="server">
Jan
- Previous message: Jan Peter Stotz: "Re: Active Directory vs SqlServer which way to go?"
- Maybe in reply to: Patrick.O.Ige: "Active Directory vs SqlServer which way to go?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]