Pass a name from SharePoint 2010 to an assessment program using the Content Editor Web Part

My earlier post explained why you might want to pass in a name from SharePoint into an assessment program via the CEWP (Content Editor Web Part), and gave the JavaScript to do this in SharePoint 2007.

SharePoint 2010 has a Client Object Model which allows much more sophisticated JavaScript programming, and here is the JavaScript to do this in SharePoint 2010. (Thanks to Mike Smith of techtrainingnotes.blogspot.com for putting me on the right track to find this.)

This is also available as a file to download. To use the file, replace the size of the iframe and the URL of the assessment system with your own. And upload it to your SharePoint site and reference it from a CEWP.

Here is a screenshot of it in use, showing user ICS\john2261 being passed through to the assessment.

I was very proud to get this working! Many SharePoint users will use Windows Authentication or a custom webpart, but this route could provide an alternate route to provide simple pass through of participant name through to low stakes assessments, and I hope it’s helpful.

2 Responses to Pass a name from SharePoint 2010 to an assessment program using the Content Editor Web Part

I’ve hit a bump with an app I’m building.
I have a PHP site with Windows Authentication enabled in IIS, which works fine on its own. But, when I go to embed it into a CEWP I get the error “Cannot retrieve the URL specified in the Content Link property.” (Weird, since “Test Link” opens it right up, with a login dialog of course.) If I enable Anonymous Authentication, however, it does retrieve the page, but returns the SQL error instead “SQLSTATE[28000]: [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user ‘NT AUTHORITY\IUSR’.1″. Its obvious in the later case that the CEWP is passing an annonymous security token, so I think that’s part of my problem.

Is there a similar method to what you have here to pass the security token for the current user from SharePoint to the other app via CEWP?

When you use the CEWP or the Page Viewer Web Part, SharePoint doesn’t intrinsically pass authentication onto the called program. It just displays it in an iframe. What I’m doing here is taking the name of the SharePoint user and passing it in JavaScript on the command line to the URL. So this is not a secure means of authentication.