Products

Solutions

Resources

Partners

Community

About

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

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...get logged in User name, and send it to another page?get logged in User name, and send it to another page?
Previous
 
Next
New Post
10/30/2009 3:26 PM
 

Any help is greatly appreciated.  We have DNN 4.9 running as out intranet.  On a different server, we have a web-based time tracking application for employees to keep their time in.  It is written in Python, and there is a Single Sign-On interface I'm trying to get working.

The python script basically takes a username, and sends it as an HTTP header to the server, then sends the user a cookie.

Since my DNN users are already logged in by the time they would use this site, I'm trying to figure out a way to dynamically grab the DNN username, and send it as an HTTP header in an ASP.net script or something.

Is there a tool that will do this, or do I have to do it manually?  I'm not very good at scripting, any help is greatly appreciated!

The python script that works (with the username hard coded) is below:

[code]
#!/usr/bin/env python
# -*- coding: utf-8; mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vim: fileencoding=utf-8 tabstop=4 expandtab shiftwidth=4

"""
##
## (C) COPYRIGHT © Journyx, Inc 1997-2008
## All Rights Reserved
## Licensed Materials - Property of Journyx, Inc.
##

"""

SVNID = '$Id$'

# IMPORTS

import urllib2, urllib, sys, genlib, nscookie, wtconfig


# CONSTANTS

# This ensures that standard Timesheet authentication is not invoked.
NOAUTHENTICATE = 1

# MAIN

def main():

    # Determine the Timesheet username or identifier.
    # Once you have it running, switch from using a constant value to whatever method you choose.
    timesheetUser = 'username'

    # Build an HTTP request object with the URL of our timesheet server and a TSUSER request header.
    timesheetUrl = 'http://servername/application'
    timesheetReq = urllib2.Request( timesheetUrl, headers={ 'TSUSER': timesheetUser } )

    class Ignore302Handler(urllib2.HTTPRedirectHandler):
        def http_error_302(self, req, fp, code, msg, hdrs):
            result = urllib2.HTTPError(req.get_full_url(), code, msg, hdrs, fp)      
            result.status = code
            return result       

    opener = urllib2.build_opener(Ignore302Handler())
    response = opener.open( timesheetReq )

    # Send the browser a 302 (redirect) response and the location to go to.
    # This is how we do it in a Timesheet CGI environment, it will be different for you.
    from daemon_session import DAEMON_SESSION
    DAEMON_SESSION.Response_Code = 302
    DAEMON_SESSION.Response_AdditionalHeaders = { 'Location': timesheetUrl }

    # Also include a cookie that we got from the Timesheet response.
    # NOTE: This is vital!  You must send the user both the cookie _and_ the redirect.
    theCookie = nscookie.cookie(path=wtconfig.options.getDocumentRoot())
    theCookie['wtsession'] = response.headers['Set-Cookie']
    genlib.wtdbg( response.headers, 'XXXYYY' )
    cookieStr = theCookie.output(expires=0, header = '', secure = wtconfig.options.isSecure())
    DAEMON_SESSION.setCookieLine( cookieStr )
    return 0
   
if __name__ == '__main__':
    main()

[/code]

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...get logged in User name, and send it to another page?get logged in User name, and send it to another page?


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