1
Jyotirmaya
Picking up windows environment variables in PHP
  • 2005/12/20 11:20

  • Jyotirmaya

  • Not too shy to talk

  • Posts: 105

  • Since: 2005/2/10


I would like to know whether there is any way to pick up the windows environment variables (eg %username%) in PHP. I believe it is possible in asp, but not sure about PHP (I use a LAMPP setup)

I am using the ldap authentication tool to authenticate users against active directory 2003 (using XOOPS 2.2). I would like to move towards a true single sign-on environment, where XOOPS automatically picks up the username and (hopefully!)password of the user currently logged in to the windows workstation (currently all my users are on windows).

I would also like to use this to design a "Call me!" support button that would submit a support email and tell me who the user was (%username%) just by them pressing a button.

Anybody have any takes on this please.
"You are never alone or helpless, the force that guides the stars guides you too"

2
davidthomas1
Re: Picking up windows environment variables in PHP

You might want to look at this open-source PHP extension for building windows apps

WinBinder

from the website:

WinBinder takes advantage of the relatively new CLI SAPI (Command Line Interface / Server Application Programming Interface) that was officially introduced in PHP 4.3.0. A custom-made DLL (a Windows library) extends PHP so it is possible to use the language to build a Windows development platform. The library includes code to manage windows, controls, messages, timers, the registry, GDI (Windows' Graphics Device Interface) and more. A set of low-level functions allows the programmer to access any Windows function, declare structures and access memory directly.


HIH
みんなちがってみんないい。

XOOPS 2.0.13.2

3
Jyotirmaya
Re: Picking up windows environment variables in PHP
  • 2005/12/20 14:23

  • Jyotirmaya

  • Not too shy to talk

  • Posts: 105

  • Since: 2005/2/10


Not sure if I understand it correctly, but I think winbinder would need a particular DLL installed on each client machine.

I would like to keep XOOPS strictly browser based (I don't really fancy having to download a dll onto each client before they can use the functionality - seems like some security issues with that)
"You are never alone or helpless, the force that guides the stars guides you too"

4
Jyotirmaya
Re: Picking up windows environment variables in PHP
  • 2005/12/20 14:42

  • Jyotirmaya

  • Not too shy to talk

  • Posts: 105

  • Since: 2005/2/10


Anybody have any experience using this:-
print_r($_SERVER)
=====================
Or I found a reference to shell_exec, something like this:-.
$blah = shell_exec ("echo %ComputerName%");
print $blah;
?>
================
Also found a reference to the GETENV command (use with remote_user ?)
http://uk.php.net/getenv
=======================
Anybody know which of these might be best to use and how to implement to populate the login form (user.php)
"You are never alone or helpless, the force that guides the stars guides you too"

5
Dave_L
Re: Picking up windows environment variables in PHP
  • 2005/12/20 14:59

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


shell_exec ("echo %ComputerName%") executes on the server, not the client, so it's not going to obtain the workstation's environment.

Similarly, $_SERVER contains info provided by the server, which includes information provided by the client's browser.

I don't think the kind of info you want is obtainable solely by PHP. You'll need some sort of client-side scripting. And client-side scripting typically won't provide the info you want (Windows username and password), because that's very insecure.

6
Jyotirmaya
Re: Picking up windows environment variables in PHP
  • 2005/12/20 15:16

  • Jyotirmaya

  • Not too shy to talk

  • Posts: 105

  • Since: 2005/2/10


hmmmmmm,

would it then be correct to say that because PHP runs all its scripts server side that this cannot be done in PHP?

Should I look at something maybe in JSP (security issues aside) that can pass these variables over to PHP somehow?

Perhaps it is possible to get a batch script to pass the environment variables onto (what?) that PHP could pick up on - I have an active directory environment where I could use policies to run batch scripts as part of the logon process....
"You are never alone or helpless, the force that guides the stars guides you too"

7
Dave_L
Re: Picking up windows environment variables in PHP
  • 2005/12/20 15:23

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Maybe. I don't know anything about JSP.

But I don't see how you're going to accomplish this without adding "something" to the clients: a .dll, a browser extension, active scripting, etc.

8
Jyotirmaya
Re: Picking up windows environment variables in PHP
  • 2005/12/20 17:40

  • Jyotirmaya

  • Not too shy to talk

  • Posts: 105

  • Since: 2005/2/10


You may be right.
I did find a way to do it if you are running IIS and have anonymous access turned off:-
http://www.phpbuilder.com/lists/php-general/2003012/0972.php

But irrelevant for me since I run Apache.
"You are never alone or helpless, the force that guides the stars guides you too"

9
davidthomas1
Re: Picking up windows environment variables in PHP

You want the clients username to autolog them into XOOPS?

If you can implement policies on your network,

You could store a cookie on each client computer with an id and their username in it.

Use an Auto-Login hack, check the cookie and there's your auto-logged in clients.
みんなちがってみんないい。

XOOPS 2.0.13.2

10
Jyotirmaya
Re: Picking up windows environment variables in PHP
  • 2005/12/21 10:53

  • Jyotirmaya

  • Not too shy to talk

  • Posts: 105

  • Since: 2005/2/10


Thanks DT,

this sounds like the most do-able solution. Will need to research how to create the cookie with policies, but have been using the autologin hack on a few sites and it works well.

Only one problem, autologin doesn't work with LDAP authentication, but I believe the Pierre-Eric who wrote the LDAP authentication code is working on this.
"You are never alone or helpless, the force that guides the stars guides you too"

Login

Who's Online

231 user(s) are online (169 user(s) are browsing Support Forums)


Members: 0


Guests: 231


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits