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...Authentication ArchitectureAuthentication Architecture
Previous
 
Next
New Post
4/21/2010 12:27 PM
 

Hi,

I am trying to integrate ADFS with DNN.  ADFS authenticates the user before it even touches the DNN code. 

I have the ADFS side working.  It redirects properly to the authentication site.  I put in my credentials, the site authenticates me, it sends me back to the return url.  I have written an HTTPModule that inspects the HTTPApplication.User.Identity and the IsAuthenticated = true and the Name = Email address.  Now I need to take this information and see if the user exists within DNN and if not I need to take the email address and log the user into.

I have looked at the AD provider and I am still trying to get the overall picture.  The HTTPModule for the provider doesn't seem to do much authentication.  The provider code doesn't seem to implment an interfaces except for its own.  The cmdLogin_Click event seems to be where you tell DNN who the user is with the call to OnAuthenticated.I am not wanting the user to have to push a button to get the login to happen.  Will this type of situation even work since the Identity is being set by ADFS?

Any help would be greatly appreciated,

Richard

 

 

 
New Post
4/21/2010 2:25 PM
 

I have extended my HTTPModule to try and modified the code that is in the cmdLogin_Click code.  The site still redirects in a way that will never resolve.  The code is as follows:

public class SSO_Module:IHttpModule
    {
        #region IHttpModule Members
        public void Init(HttpApplication context)
        {
            context.AuthorizeRequest += new EventHandler(context_AuthorizeRequest);              
        }
        void context_AuthorizeRequest(object sender, EventArgs e)
        {
            HttpApplication app = (HttpApplication)sender;
           
            SSO.SingleSignOnIdentity id = (SSO.SingleSignOnIdentity)app.User.Identity;
            app.Response.Write("IsAuthenticated:" + id.IsAuthenticated.ToString() + "
");
            app.Response.Write("Name:" + id.Name + ", " + id.NameType + "
");
           
            app.Response.Write("

Claims


");
            foreach (SecurityProperty sp in id.SecurityPropertyCollection)
            {
                app.Response.Write(sp.Name + " - " + sp.Value +"
");
            }

 

            try
            {
                UserCreateStatus objUserCreateStatus;

                //'See if user exists in DNN Portal user DB
                UserInfo objUserInfo = UserController.GetUserByName(0, id.Name);

                //' user does exist - try to create on the fly
                if (objUserInfo == null)
                {
                    objUserInfo = new UserInfo();

                    objUserInfo.DisplayName = id.Name;
                    objUserInfo.FirstName = id.Name;
                    objUserInfo.LastName = id.Name;
                    objUserInfo.Username = id.Name;
                    objUserInfo.Membership.Password = "reallyhardpassword";
                    objUserInfo.PortalID = 0;
                    objUserInfo.Email = id.Name;
                    objUserCreateStatus = UserController.CreateUser(ref objUserInfo);

                    if (objUserCreateStatus == UserCreateStatus.Success)
                    {
                        LetsLogUserIn(objUserInfo, app.Response);
                    }
                    else
                    {
                        objUserInfo = null;
                    }
                }
                else
                {
                    LetsLogUserIn(objUserInfo, app.Response);
                }

                //app.Response.Write("leaving check dnn user for " + objUserInfo.DisplayName);
            }
            catch (Exception ex)
            {
                //DotNetNuke.Services.Exceptions.LogException(ex);               
            }
        }
        private void LetsLogUserIn(UserInfo objUserInfo, HttpResponse response)
        {
            try
            {
                //'Lets log the user in
                UserLoginStatus loginStatus;

                response.Write(
                    "Login check dnn user: current/checking " +
                    "/" + objUserInfo.Username);
           

                Localization.SetLanguage(DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings().DefaultLanguage);

                response.Write("Log them in - INFO coming....");
                response.Write("Log them in user/potal/pid " + objUserInfo.Username);
                UserController.UserLogin(0,
                                         objUserInfo,
                                         "My Website",
                                         HttpContext.Current.Request.UserHostAddress,
                                         false);
                response.Write("Logged in completed");
                
            }
            catch(Exception ex)
            {
                //DotNetNuke.Services.Log.EventLog.logex.Services.Exceptions.LogException(ex);               
            }
        }
 

Any help would be greatly appreciated

 
New Post
4/22/2010 4:30 PM
 
Any idea at all?
 
New Post
4/27/2010 12:48 PM
Accepted Answer 

As It turns out, I was responding to the wrong event.  Instead of the AuthorizeRequest event, I needed to respond to the AuthenticateRequest event.  The AuthorizeRequest event never got fired. 

I will post a more complete solution in another thread once I get it together.

Thanks,

Richard

 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsOther Extension...Other Extension...Authentication ArchitectureAuthentication Architecture


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