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...Building ExtensionsBuilding ExtensionsOther Extension...Other Extension...Developing a new Authentication SystemDeveloping a new Authentication System
Previous
 
Next
New Post
4/12/2010 11:57 AM
 
Hi all,

I am quite new to DNN/.Net development so feel free to correct me as I go along.

I have started building an authentication provider that would use information obtained from the HTTP Header to "automatically" log the user into DNN. The idea would be to have DNN sitting behind some 3rd party access management tool (i.e. Siteminder). The user would authenticate into the 3rd party tool which would then redirect them to the DNN home page. When the user is authenticated with the 3rd party tool, a set of HTTP Headers are created. One element would be the user id of the person logged in (i.e. SM_USER).

The DNN Authentication Module would sit on the home page. When the page loads, the authentication provider would read what HTTP Header element to look for, obtain the user id from that element, and log into DNN with no intervention from the user. If, for some reason, DNN could not authenticate the user id, then the user would be redirected to another address provided in the settings area.

I have started a project on CodePlex but there was a server error of some sort and I will post the project that I have so far when I can. The intention would be to make it public domain and hope that it helps someone including myself. In the meantime, does anybody have any recommendations as to how to proceed?

Currently, I am having a problem just reading from the settings section of the module. Below is the login.ascx.cs file that I currently have. Any suggestions or comments would be appreciated. Thanks.

using System;
//using System.Collections;
using System.Collections.Specialized;
using System.Reflection;
using System.Web;
using DotNetNuke.Services.Authentication;
using DotNetNuke.UI.Utilities;
using DotNetNuke;
using DotNetNuke.Entities.Users;
using DotNetNuke.Security.Membership;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Services.Exceptions;


namespace IAPWS.Modules.HeaderAuthentication
{

public partial class Login : AuthenticationLoginBase
{

private string _appID;
private string _sHeader; // Used to identify what HTTP Header will contain the username of the pre-validated user.
private string _sUserName; // Used to store the actual username of the logged in user.
private string _sFailedLoginURL; // If authentication in DNN fails, where do I go? (HTTP Address)
private string _sLogoutURL; // When the user clicks logout, where do I go? (HTTP Address)
UserInfo objUser;
//bool bAmAdmin; // Is this person listed as an administrator?


#region Public Properties
public string AppID
{
get { return _appID; }
set { _appID = value; }
}

public string sHeader
{
get { return _sHeader; }
set { _sHeader = value; }
}

public string sUserName
{
get { return _sUserName; }
set { _sUserName = value; }
}

public string sFailedLoginURL
{
get { return _sFailedLoginURL; }
set { _sFailedLoginURL = value; }
}

public string sLogoutURL
{
get { return _sLogoutURL; }
set { _sLogoutURL = value; }
}

public override bool Enabled
{
get { return AuthenticationConfig.GetConfig(PortalId).Enabled; }

}

public string ReturnURL
{
get { return Null.NullString; }
}
#endregion

#region Private Methods
private void loginUser(string pUserName)
{
//Try and Log User into DNN
UserLoginStatus loginStatus = UserLoginStatus.LOGIN_FAILURE;

// Alterations to be done..
// user object will need to be populated.
UserInfo objUser = UserController.ValidateUser(PortalId, pUserName, "DNN", "", PortalSettings.PortalName, IPAddress, ref loginStatus);

//Raise UserAuthentication Event
UserAuthenticatedEventArgs eventArgs = new UserAuthenticatedEventArgs(objUser, sUserName, loginStatus, "DNN");

OnUserAuthenticated(eventArgs);
}
#endregion

#region Protected Methods

protected override void OnInit(EventArgs e)
{
base.OnInit(e);
}

protected override void OnLoad(EventArgs e)
{
// This is the key area..
// 1. Obtain HTTP Header marker to look for.
// 2. Using HTTP Header marker, obtain username.
// 3. Log user into DNN using username.


try
{

// 1. Obtain HTTP Header marker (i.e. SM_USER) to look for. Obtain the redirect to an error page.
AuthenticationConfig config = AuthenticationConfig.GetConfig(PortalId);
sHeader = config.HeaderVariable;
sFailedLoginURL = config.FailedLoginURL;

// 2. Using username header marker, obtain username from header.
NameValueCollection colHeaders = req.Headers;
sUserName = colHeaders.GetValues(sHeader);

// 3. Log user into DNN.
loginUser(sUserName);
}
catch (Exception exc)
{
HttpResponse res = HttpContext.Current.Response;
res.Redirect(sFailedLoginURL, true);

}
//base.OnLoad(e);
}

#endregion

}

}
 
New Post
4/13/2010 1:13 AM
 

Might not be the answer you're looking for though it seems to fit with what you're wanting to do...

As a non-programmer myself, I'd look at using OpenWebStudio for this.  It could look at querystrings etc and then automatically log in users, without needing to enter passwords or anything using the custom authentication as described here > http://www.openwebstudio.com/Communit...

Might help.

 
New Post
4/20/2010 1:33 PM
 
Found what the problem was. Was using a completely wrong methodology for storing the settings information to begin with.

Thanks!
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsOther Extension...Other Extension...Developing a new Authentication SystemDeveloping a new Authentication System


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