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]