Sunday, November 29, 2009

Here is some of sample code how you can check current user has admin rights

If Not PortalSecurity.IsPageAdmin() Then
Dim imgbtn As ImageButton = showeventdetails.FindControl("ImageButton1")
imgbtn.Visible = False
End If

If action.Visible And PortalSecurity.HasNecessaryPermission(action.Secure, PortalSettings, ModuleControl.ModuleContext.Configuration) Then
                                    If (ModuleControl.ModuleContext.EditMode = True AndAlso IsAdminControl() = False) OrElse _
                                            (action.Secure <> SecurityAccessLevel.Anonymous AndAlso _
                                             action.Secure <> SecurityAccessLevel.View) Then
                                        Dim ModuleActionLink As New LinkButton
                                        ModuleActionLink.Text = action.Title
                                        ModuleActionLink.CssClass = "CommandButton"
                                        ModuleActionLink.ID = "lnk" & action.ID.ToString

                                        AddHandler ModuleActionLink.Click, AddressOf LinkAction_Click

                                        Me.Controls.Add(ModuleActionLink)
                                        Dim Spacer As New LiteralControl(ItemSeparator)
                                        Me.Controls.Add(Spacer)
                                    End If


No comments:

Post a Comment