This is DNN4, and I didn't write it, but here is the code ripped from our container that does just this. I will let you slog thru and decide which parts you don't need:
Here is the line from the container's ascx file...
<DNN:DNNToolBar id="tbEIPTitle" runat="server" CssClass="eipbackimg" ReuseToolbar="true">...
and code from the ascx.vb file...
Private Function CanEditModule() As Boolean
Dim blnCanEdit As Boolean = False
Dim objModule As Entities.Modules.PortalModuleBase = Container.GetPortalModuleBase(Me)
If (Not objModule Is Nothing) AndAlso (objModule.ModuleId > Null.NullInteger) Then
blnCanEdit = (PortalSettings.UserMode = PortalSettings.Mode.Edit)
AndAlso (PortalSecurity.IsInRoles(PortalSettings.AdministratorRoleName)
OrElse PortalSecurity.IsInRoles(PortalSettings.ActiveTab.AdministratorRoles.ToString))
AndAlso (IsAdminControl() = False)
AndAlso (PortalSettings.ActiveTab.IsAdminTab = False)
End If
Return blnCanEdit
End Function
and...
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
...
If CanEditModule() = False OrElse Entities.Portals.PortalSettings.GetSiteSetting(objPortalModule.PortalId, "InlineEditorEnabled") = "False" Then
lblTitle.EditEnabled = False
tbEIPTitle.Visible = False
....