RSS feed icon BTB Shadow Man BiteTheBullet.co.uk logo
Average Rating: 
Whole StarWhole StarWhole StarHalf StarEmpty Star

Total number of ratings: 5

Adding a Logout Option to the Admin Menu in DotNetNuke

Adding a Logout Menu Item

Admin menu with an added Logout optionI wanted to remove the login/logout option from a DotNetNuke portal on a couple of projects, and allow the administrator to access the login page using the standard login url and to add a logout option in the admin menu.

Removing the login/logout link is straight forward, just remove the [LOGIN] token from the portal skin. Adding the option to the admin isn't much more difficult.
I've tested this in DNN 3.x and 4.x both versions work fine.


Login to the portal with the host account, then select Host -> SQL. Copy the sql script below into the window and select Run as script option. You'll need to set the @portalId parameter to the value of your portal if you have more than one portal.
declare @portalId int
declare @roleId int
declare @adminTabId int

set @portalId = 0;


--work out the admin tabId
select @adminTabId = tabId from {objectQualifier}tabs where TabName='Admin' and portalId=@portalId


--insert the tab entry
insert into {objectQualifier}tabs (TabOrder, PortalId, TabName, IsVisible, ParentId, [Level],
            title, [description], TabPath)
        values (20000, @portalId, 'Logout', 1, @adminTabId, 1, 'Logout', '', '//Admin//Logout')


declare @tabId int

select @tabId = @@identity

--get the administrator role for this portal
select @roleId = roleId from {objectQualifier}roles where portalId=@portalId and rolename ='Administrators'


--add the permissions to the tab_permissions table
insert into {objectQualifier}tabpermission (tabId, permissionId, roleId, allowAccess)
        values(@tabId, 3, @roleId, 1)

 



Then simple copy this xml snippet into the SiteUrls.config file in the root of the site, this snippet should be the first entry in the rules.

<RewriterRule>
  <LookFor>.*/Admin/Logout/.*</LookFor>
  <SendTo>~/Admin/Security/Logoff.aspx</SendTo>
</RewriterRule>


Here is what the SiteUrl.config should look like after editting it, the highlighted section shows the new entry we have just created.
SiteUrl.config after editting
Then simple either clear the cache or restart the application depending on if you have DNN 3 or 4.

Removing the Admin Option
If you later want to remove the Logout option from the admin menu use the following sql script which you should execute again using Host -> SQL with the Run as script option ticked.

declare @logoutTabId int
declare @portalId int

set @portalId = 0;

select @logoutTabId=tabId from {objectQualifier}tabs where portalId=@portalId and tabName='Logout' and tabPath='//Admin//Logout'

delete from {objectQualifier}tabpermission where tabId=@logoutTabId
delete from {objectQualifier}tabs where tabId=@logoutTabId

 

Privacy PolicyTerms and ConditionsCopyright © 2005 - 2010 BiteTheBullet.co.uk