user interaction

Jan 29, 2011 at 5:24 AM

i want to filter according to user login

how do i  get the details of user login to DNN to filter SQL?

Coordinator
Jan 29, 2011 at 9:02 AM

Hello,

You can use mdo:dnn() function to get access to DNN environment.
http://xsltdb.codeplex.com/wikipage?title=mdo:dnn 

The sample below just prints a list of current user roles.

<xsl:variable name="sql">
    select r.* from {databaseOwner}[{objectQualifier}UserRoles] ur
    join {databaseOwner}[{objectQualifier}Roles] r on r.RoleID = ur.RoleID
    where ur.UserID = @UserID;
</xsl:variable>
<xsl:variable name="roles" select="mdo:sql($sql, 'role', '@UserID', mdo:dnn('U.UserID'))"/>
<ul>
  <xsl:for-each select="$roles//role">
    <li>{{RoleName}}</li>
  </xsl:for-each>
</ul>

P.S. If you know your actual table name you can avoid using {databaseOwner} and {objectQualifier}.

 

 

Jan 30, 2011 at 2:56 AM

<mdo:asp xmlns:asp="asp" xmlns:telerik="telerik">
      <asp:SqlDataSource
          id="dsFlights"
          runat="server"
          EnableCaching="False"
          ConnectionString=""
          SelectCommand="SELECT * FROM [].[dbo].[vw_myFlights]"
             />
      <telerik:RadGrid
 


          AllowPaging="True"
          PageSize="10"

          AutoGenerateColumns="True"

          AllowAutomaticDeletes="False"
          AllowAutomaticInserts="False"
          AllowAutomaticUpdates="False"

          Skin="Office2007"
          runat="server">

        <MasterTableView DataSourceID="dsFlights" >
        
        </MasterTableView>
      </telerik:RadGrid>
 

</mdo:asp>



this is what i wrote

how i filter SELECT * FROM [].[dbo].[vw_myFlights] where userd=@userid

Coordinator
Jan 30, 2011 at 6:27 AM

In this sample you have list of roles assigned to current user (don't test under super user since it doesn't have any role assigned).

Just replace dnn_UserRoles with your vw_myFligh ts view to get what you need.

<mdo:asp xmlns:asp="asp" xmlns:telerik="telerik">
      <asp:SqlDataSource
          id="dsFlights"
          runat="server"
          EnableCaching="False"
          ConnectionString="&lt;%$ ConnectionStrings:SiteSqlServer %&gt;"
          SelectCommand="SELECT * FROM dnn_UserRoles WHERE UserID = @UserID"
      >
        <SelectParameters>
          <asp:Parameter
          	Name="UserID"
          	DefaultValue="{mdo:dnn('U.UserID')}"/>
        </SelectParameters>
      </asp:SqlDataSource>
      <telerik:RadGrid
  


          AllowPaging="True"
          PageSize="10"

          AutoGenerateColumns="True"

          AllowAutomaticDeletes="False"
          AllowAutomaticInserts="False"
          AllowAutomaticUpdates="False"

          Skin="Office2007"
          runat="server">

        <MasterTableView DataSourceID="dsFlights" >
         
        </MasterTableView>
      </telerik:RadGrid>
 

</mdo:asp>