Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

telerik -- supercharge your DNN websites
  Ads  
Iron Speed Designer is a software development tool for building database, reporting, and forms applications for .NET without hand-coding.
 


  Sponsors  

Meet Our Sponsors

Verndale
The Official Microsoft ASP.NET Website
Portal Webhosting - Hosting For Developers
Red-Gate Software
MaximumASP
SourceGear - Tools for Developers
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Extend It! ( Pr...  Determining current user
Previous Previous
 
Next Next
New Post 8/14/2007 11:36 PM
User is offline Redjac
29 posts
10th Ranked


Determining current user 

I am trying to modify the Dot Net Nuke Menu.  I have added a conditional to the ist building section of the menu.  The goal is to make sure that even if a user is an Admin User, they can only see the Admin tabs if they are user_ID 1 or 2.  The problem is that I need to load objUserInfo.UserID with information about the current user.  How can I extract the username of the current user as a string?  Is this a secure thing to do?  I would appriciate hearing better ideas if anyone has one.

 

Dim objUsers As New Entities.Users.UserController
Dim objUserInfo As Entities.Users.UserInfo

objUserInfo = objUsers.GetUserByUsername(MyPortalSettings.PortalId, <Username As String> )

<...some more code ....>

 

' Build list of tabs to be shown to user
    For i = 0 To MyPortalSettings.DesktopTabs.Count - 1

      Dim tab As TabInfo = CType(MyPortalSettings.DesktopTabs(i), TabInfo)
      If tab.IsVisible = True And tab.IsDeleted = False Then
                If DotNetNuke.Security.PortalSecurity.IsInRoles(tab.AuthorizedRoles) = True Then
                    If (tab.IsAdminTab = True And (objUserInfo.UserID = 1 Or objUserInfo.UserID = 2)) Or tab.IsAdminTab = False Then
                        authorizedTabs.Add(tab)
                        addedTabs += 1
                    End If
                End If
            End If

        Next i

 
New Post 8/15/2007 5:06 AM
User is offline Wes Tatters
410 posts
8th Ranked




Re: Determining current user 

The UserController can return the current userinfo object.

DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo()

Westa

 
New Post 8/15/2007 12:49 PM
User is offline Lynne
44 posts
10th Ranked


Re: Determining current user 

I'm trying to convert an existing asp1.1/dnn2.0 to asp2.0/dnn4.x...  it's some code that when logged in a user can become another user (ie home office associate can log in as a customer and see the site the way the customer would see it).

I'm lost. Here's my error

System.Data.SqlClient.SqlException: Conversion failed when converting the varchar value 'Lynne' to data type int. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.HasMoreRows() at System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout) at System.Data.SqlClient.SqlDataReader.Read() at System.Data.SqlClient.SqlCommand.CompleteExecuteScalar(SqlDataReader ds, Boolean returnSqlValue) at System.Data.SqlClient.SqlCommand.ExecuteScalar() at DotNetNuke.BecomeaUser.IDCheck() at DotNetNuke.BecomeaUser.Page_Load(Object sender, EventArgs e)

I tried implementing you GetCurrentUserInfo()

 

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load' Obtain PortalSettings from Current Context

Try

DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo()

 

'Dim _portalSettings As ProviderSettings = CType(Context.Items("PortalSettings"), ProviderSettings)

IDCheck()

 

' Log User Off from Cookie Authentication System

 

Dim vUserId As String

 

' Dim vPass As String

 

If (Request.Params("Agentid") <> "") Then

vUserId = Request.Params(

Session(

Response.Cookies(

"Agentid")"pRet") = vAgentid"Sub").Value = "555555555"

Response.Cookies(

"Sub").Path = "/"

 

Else

vUserId = Session(

Session(

"pRet").ToString"pRet") = ""

 

End If

 

 

Dim objSecurity As New Security.PortalSecurityDim blnLogin As Boolean = True

 

If blnLogin Then

 

' Attempt to Validate User Credentials

 

Dim userId As String = vUserId 'objSecurity.UserLogin(vUserId, vPass, 0, 0, 0, 0)

 

If userId >= 0 Then

formsAuthentication.SignOut()

 

' expire cookies

Response.Cookies(

"portalid").Value = Nothing

Response.Cookies(

"portalid").Path = "/"

Response.Cookies(

Response.Cookies(

"portalid").Expires = DateTime.Now.AddYears(-30)"portalroles").Value = Nothing

Response.Cookies(

"portalroles").Path = "/"

Response.Cookies(

Response.Cookies(

"portalroles").Expires = DateTime.Now.AddYears(-30)"Sub").Value = Nothing

Response.Cookies(

"Sub").Path = "/"

Response.Cookies(

formsAuthentication.SetAuthCookie(Convert.ToString(userId),

Response.Redirect(

 

"Sub").Expires = DateTime.Now.AddYears(-30)False)"~/" & "tabid/36/Default.aspx")Else

Response.Write(

 

"This User is not yet created to be a Web User.2")End If

 

End If

 

Response.Write(ex.ToString)

 

Catch ex As ExceptionEnd Try

 

End Sub

I'm not having much luck searching so I'm asking in this thread.  PLEASE... even a search suggestion would help.

 

 
New Post 8/15/2007 2:28 PM
User is offline Vitaly Kozadayev
753 posts
www.continure.com
7th Ranked






Re: Determining current user 
Modified By Vitaly Kozadayev  on 8/15/2007 11:30:30 PM)

You don't need to do either one of these things.

IF YOU ARE BUILDING A MODULE, your module should be extended from DotNetNuke.Entities.Modules.PortalModuleBase. In this case, current UserId is explicitly available to you and you can refer to it just like that If UserId = 1 Then... You don't need to do any queries, you don;t need to populate anything.

Another point, if you want to test current user if he/she is a SuperUser or and Admin, you can just say 
If UserInfo.IsSuperUser OrElse UserInfo.IsInRole("Administrator") Then...


Vitaly Kozadayev
Principal
Viva Portals, L.L.C.
 
New Post 8/15/2007 6:50 PM
User is offline Wes Tatters
410 posts
8th Ranked




Re: Determining current user 

That would assume he was building a MODULE

- but since he says he is modifying the DNN MENU I kinda assumed he is working on a SKIN  - in which case you would not be extending PortalModuleBase.

Westa

 
Previous Previous
 
Next Next
  Forum  General DotNetN...  Extend It! ( Pr...  Determining current user
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, please observe the following posting guidelines:

1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


Vekkin Solutions
Vekkin Solutions provides complete website solutions and custom module development to churches and small businesses.
www.vekkin.com
Powered by Adcuent®.Com
Adcuent® Consulting & Technology offers custom development web applications and hosting projects under the brand of Powered by Adcuent®.Com
www.adcuent.com
Easily Build DNN Solutions with XMod
XMod makes it easy to build news articles, house listings, custom feedback forms, product reviews and much more - without programming
www.DNNDev.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP