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

HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsAuthenticationAuthenticationCentral Authentication Service - CASCentral Authentication Service - CAS
Previous
 
Next
New Post
5/24/2007 4:00 PM
 

http://www.ja-sig.org/products/cas/

I'm new to DNN, but here's what I'm wanting to accomplish.

When a user hits the DNN site they are bounced over to authenicate against our single sign on system.  

After they have successfully authenicated, they are directed back to the DNN site with a username (see code below).  We're using C
AS for authnitication, using the following code, I can authenticate a user getting their username.

What I'd like to do is if the username does not exist in DNN, create it in DNN, if it does, go ahead and "log them in" with the username retrieved from the CAS code.

Again, I'm new to DNN, I was hoping someone has already been down this road and could help me get started.

Thanks,

Kyle

/** 
* CASP.cs 
* CAS over ASP.NET! 
*  
* Created by John Tantalo, john.tantalo@case.edu 
* Case Western Reserve University 
*  
* Modification History: 
*  
* 12/09/05 jnt5, created class 
* 12/12/05 jnt5, removed cookie check 
*                                stores CASNetworkID in session instead of cache 
*                                clears Page session variable after ticket verification 
* 12/13/05 jnt5, removed Page session variable 
*                                fixed bug which would cause loop due to incorrect service parameter 
* 04/04/06 jnt5, adapted serviceURL code courtesy Ali Cakmak 
* 04/10/06 jnt5, added new comments 
*  
* References: 
*  
* http://wiki.case.edu/Central_Authentication_Service 
* https://clearinghouse.ja-sig.org/wiki/display/CAS/CAS+2.0+Protocol+Specification 
*/ 
 
using System ; 
using System.Web.UI ; 
using System.Net ; 
using System.IO ; 
using System.Web.SessionState; 
 
/** 
* CASP general usage: 
*  
*      private void Page_Load(object sender, System.EventArgs e) 
*      { 
*              String NetworkID = CASP.Authenticate( "https://bb5.fsu.edu/cas/login", "https://bb5.fsu.edu/cas/validate", this ) ; 
*      } 
*/ 
          
public class CASP 
{ 
        /** 
         * Authenticates a user with the given login and validation pages. After authentication 
         * the user's browser is redirected to the original page. 
         */ 
         
        public static String Authenticate( String LoginURL, String ValidateURL, Page Page ) 
        { 
                return Authenticate( LoginURL, ValidateURL, Page, Page.Request.Url.AbsoluteUri.Split('?')[0] ) ; 
        } 
 
        /** 
         * Authenticates a user with the given login and validation pages. After authentication 
         * the user's browser is redirected to the location given as the service URL. 
         */ 
 
        public static String Authenticate( String LoginURL, String ValidateURL, Page Page, String ServiceURL ) 
        { 
                if( Page.Session["CASNetworkID"] != null ) // user already logged in 
                        return Page.Session["CASNetworkID"].ToString() ; 
                else // user hasn't logged in 
                { 
                        if( Page.Request.QueryString["ticket"] != null ) // ticket received 
                        { 
                                try // read ticket and request validation 
                                { 
                                        StreamReader Reader = new StreamReader( new WebClient().OpenRead( ValidateURL + "?ticket=" + Page.Request.QueryString["ticket"] + "&service=" + ServiceURL ) ) ; 
                                 
                                        if( "yes".Equals( Reader.ReadLine() ) ) // ticket validated 
                                        { 
                                                // store network id in sesssion, return value 
 
                                                return (String) ( Page.Session["CASNetworkID"] = Reader.ReadLine() ) ; 
 
                                        } 
                                }  
                                catch( WebException ) {} 
                        }  
         
                        // ticket was invalid, or didn't exist, so request ticket 
                 
                        Page.Response.Redirect( LoginURL + "?service=" + ServiceURL, true ) ; 
                        return null ; 
                 } 
        } 
} 
 
New Post
5/24/2007 4:24 PM
 

http://www.ja-sig.org/products/cas/

I'm new to DNN, but here's what I want to accomplish.

When a user hits the DNN site they are bounced over to authenticate against our single sign on system.  

After they have successfully authenticated, they are directed back to the DNN site with a username (see code below).  We're using CAS for authentication, using the following code; I can authenticate a user getting their username.

What I'd like to do is if the username does not exist in DNN, create it in DNN, if it does, go ahead and "log them in" with the username retrieved from the CAS code.

Again, I'm new to DNN, I was hoping someone has already been down this road and could help me get started.

 

 
New Post
5/24/2007 5:59 PM
 
 
New Post
5/24/2007 6:00 PM
 

Most likely your best bet is to automatically create the account for the user and give it a set password.  You can then log the user in manually after you have validated the account since you are aware that the login was correct.

If you need help with the code for account creation and/or login let me know I have now built about 4 modules that do this type of thing...


-Mitchel Sellers
Microsoft MVP, ASPInsider, DNN MVP
CEO/Director of Development - IowaComputerGurus Inc.
LinkedIn Profile

Visit mitchelsellers.com for my mostly DNN Blog and support forum.

Visit IowaComputerGurus.com for free DNN Modules, DNN Performance Tips, DNN Consulting Quotes, and DNN Technical Support Services
 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsAuthenticationAuthenticationCentral Authentication Service - CASCentral Authentication Service - CAS


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