Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Using JQuery in DNN HTML Module for RAD?Using JQuery in DNN HTML Module for RAD?
Previous
 
Next
New Post
12/19/2010 5:33 PM
 
Here is a module using techniqs like this.
Made by Joe Brinkman.
http://dnnnotes.codeplex.com/releases...
 
New Post
12/21/2010 1:17 AM
 
Thanks Jan. Joe Brinkman's example is the most intriguing so far. While it uses Android as a client as opposed to jQuery/json, I think the principles still apply.

However, I'm still not clear on how it generates a token. Is there a call it sends to the webservice with a username/password which returns a token, and that token then maps to a userid/portalid/etc.?

Since we're not designing for mobile devices, I wonder if that's the best model for our needs. Isn't there a way to rely on DNN's cookie and built in security architecture to know when a user is logged in and what their userid and portalid are?

 
New Post
12/21/2010 1:33 AM
 
Ok, it does generate a token as I thought. Send a command over the wire with username and password and it returns the token. This is great for mobile, but does not work in a web environment where they have already logged in once. Logging in twice is not user friendly.

There must be an elegant way to integrate with the DNN security architecture and read a cookie that tells you a userid/portalid
 
New Post
12/21/2010 1:50 AM
 
Lucas,
  You don't actually need a token at all.  The users authentication status and the roles they have access to are stored in cookies.  Since cookies are submitted from the client to the server with every request, the server already has all the information necessary to make sure that the web client has the needed permissions.  In your service layer just include a check a check to see if a user is in a specific role -

Imports DotNetNuke.Entities.Users

if UserController.GetCurrentUserInfo.IsInRole("myRole") then doSomething()

If you are using WCF, you will need to make sure it is configured to operate with HTTPContext, but if you use standard ASMX, then this will work without any problems.

In my dnnNotes example I couldn't take advantage of cookies since I was not accessing the framework from an environment that uses cookies and thus I needed an alternate authentication method.

Joe Brinkman
DNN Corp.
 
New Post
12/21/2010 2:51 AM
 
Thanks for the response, Joe. I knew it had to be easy!

However, when I try to use that method with an ASMX it doesn't recognize the logged in user. This is what I get from UserInfo:

{DotNetNuke.Entities.Users.UserInfo}
    base {DotNetNuke.Entities.BaseEntityInfo}: {DotNetNuke.Entities.Users.UserInfo}
    AffiliateID: -1
    Cacheability: notCacheable
    DisplayName: null
    Email: null
    FirstName: null
    FullName: " "
    IsDeleted: false
    IsSuperUser: false
    LastIPAddress: null
    LastName: null
    Membership: {DotNetNuke.Entities.Users.UserMembership}
    PortalID: -1
    Profile: {DotNetNuke.Entities.Users.UserProfile}
    RefreshRoles: false
    Roles: {string[0]}
    UserID: -1
    Username: null

It should recognize me as Host and UserID 1 since I am logged in at the same time. 


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using DotNetNuke.Entities.Users;
using System.Web.Script.Services;
using DotNetNuke.Entities.Modules;
 
namespace YourCompany.Modules.QuantumToolsModules
{
    /// <summary>
    /// Summary description for TestQuantumTools
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    [ScriptService]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    // [System.Web.Script.Services.ScriptService]
    public class TestQuantumTools : PortalModuleBase // System.Web.Services.WebService
    {
 
        [WebMethod]
        public string GetUsersFrmRl(string AppNm, string SetNm, string Flg, int P_id, int U_id, string PD)
        {
            string ret_str = string.Empty;
            UserController uc = new UserController();
            //UserInfo ui = uc.GetUser(P_id, U_id);
            UserInfo ui = UserController.GetCurrentUserInfo();
 
            return ret_str;
        }
    }
}

Which was called from a $.ajax command, which we debugged after it hit the UserInfo and returned the previous block.

The lunar eclipse is winding down now, so I'm off to sleep! Not a very exciting a event, but at least I've seen one.
 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Using JQuery in DNN HTML Module for RAD?Using JQuery in DNN HTML Module for RAD?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, 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 DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out