You are here

Passing user's displayName to php script

Submitted by baumli on Mon, 07/21/2008 - 14:09

I'm working on a shoutbox program written in php, and would like to grab the user's name, rather then have them type something in a text field. Does anyone know of a way to get the user information from the session? I was thinking that I could grab the name using a jsp page first, then pass that as a parameter to the php page. I looked at the welcome message, but I can't get it to display when I just take the snippet to a different page. Anyone have any ideas? This is a step towards several other programs we need, but have to get the user information figured out before I can continue.

Luminis Version:

Comments

I'm doing something similar. I have a channel that proxies an .asp page hosted on another server.

When luminis pulls in the proxied page, it passes the username to the IIS server and the IIS server returns a set of HTML with the usernme buried inside a hidden form element.

So:

1. User logs in to Luminis
2. Users's layout includes a Web Proxy Channel
3. Luminis makes a request to an external webserver. The HTTP request includes a POST of the IPerson parameters that I want passed to the external web server.
4. The external web server takes the POST data, does some gyrations against a database, builds some XHTML dynamically and returns it to Luminis.
5. Luminis displays the XHTML, tailored specifically for this user, in the channel.

Is this a pain in the butt? Yes, definitely. But it was the only way I could figure to make it work.

For this to work you need to create a web proxy channel using the following parameters:

Channel Type: Web Proxy
Channel Title: My Cool Channel
Channel Name: My Cool Channel
Channel Functional Name: My Cool Channel
Channel Description: Description of My Cool Channel
Channel Timeout: 5000milliseconds
Application URI (cw_xml) http://myIISorPHPserver.someschool.edu/path/to/the/page/index.asp
Default Cache Mode (cw_cacheDefaultMode) none
Restrict IPerson Attributes Passing to These (cw_personAllow) urn:sungardhe:dir:role,urn:mace:dir:displayName,username,urn:sungardhe:dir:loginId
Default IPerson Attributes to Pass (cw_person) urn:sungardhe:dir:role,urn:mace:dir:displayName,username,urn:sungardhe:dir:loginId
Enable HTML Filter? (cw_tidy) on
Default Cache Timeout (in seconds) (cw_cacheDefaultTimeout) 900
Pass-through Type (cw_passThrough) application
Application SSL (cw_ssl) XHTML.ssl
*Selected Categories: Some category
*Selected Groups and/or People: Role = public (or whatever)

Note a few things:

1. This is NOT secure. The parameters being passed are being sent in clear text.
2. The longer the round trip to the external server being proxied, the greater the chance that the channel will time out. Be sure to have a nice robust machine serving this page and, if you're doing any fancy footwork with the POSTed data between the http request and the response, you may need to increase the timeouts on the luminis side.
3. There is a built in channel that comes with Luminis 4 that allows you to see what IPerson attributes you can send using the web proxy channel. To get to it, create a custom channel using these parameters:

Channel Type: Custom
Channel Title: iPersonAttributes
Channel Name: iPersonAttributes
Channel Functional Name: iPersonAttributes
Channel Description: iPersonAttributes
Channel Timeout: 5000milliseconds
Channel Secure:
Channel Class: org.jasig.portal.channels.CPersonAttributes
*Selected Categories: Other
*Selected Groups and/or People: ( Role = admin AND Role = public )

Add that channel to your layout and you should get a list of the iPerson attributes that you can pass.

Worked perfectly! Basically this does the work of the jsp file I was trying to create. Thanks for the detailed explanation.

It works great! but the only trouble i got is to get all the roles in "urn:sungardhe:dir:role".

When I do $_get for role in php: $role= $_GET["urn:sungardhe:dir:role"] or $role= $_GET["urn:sungardhe:dir:role"][2];;
It simply return my last role. Tried with array and looping it and it just won't work.

Any idea? (apologise if it might related more to php here..)

Thanks

When I first did this I found that the iPerson attributes were not being passed. I put in a ticket to Sungard and found that there was a bug in version IV. You need version IV.0.2 or higher for this to work. See SR# 1-202932311 on connect.sungardhe.com for details.

The only problem I'm having is that whenever I submit a form, the results are going to a new page, instead of staying within the channel. Other channels that I've done this in, I've made them inline frame channels, so it stays in. Any ideas on how to keep it within the channel?

On an inline frame channel, I can do target="_top", but in this channel, the only target that works is blank which opens a new window.

there's supposed to be a way to do this and its (IMHO) buggy at best.

If you look at the screen when you're creating / editing the webproxy channel, you'll see something that reads like this :

Pass Through Type [none/marked/application/all]

If you read the ramblings in the help popup (version III.3.3.x) - it basically tells you that

none - links / form posts take over the browser
marked - supposed to be able to specify which links reload in the frame and which launch out / take over "simply" by adding ?cw_InChannelLink=1 to the link or action of a form
application - keeps links / form posts of the application in the channel
all - keeps all links / form posts in the channel

now - I've never been able to get marked to work right, and can't really tell you the difference (or implementation) of application vs. all

If you choose "all" or "application" and view the source of the page, you'll see that all the links and action urls are modified so the clicks go back through luminis to be processed. Its a kinda cool concept, if you can get it to work right.

I _think_ you want "all" here for your though, if I'm reading it correctly.
You can change that option in your channel, then I think you have to log out and back in for it to take effect.

I WISH - you could have an AJAX option that simply refreshes itself with no page refresh. Can't be that hard to do, right? .. maybe I'll get to work on that :)

Good luck !
-Jon

If you ever find that you need more control over the channel type, and would instead want to use a jsp page, searching my blog or this site for iPerson and JSP will get you several methods.

We currently use JSP and the iPerson object on Luminis IV.0.1.60 to pass user ldap info to multiple external systems with a single jsp page.