How can I get a custom Windows username from my PHP application?

My reason for posting here is because it is still not clear to me what specific requirements must be met for this.

We run our PHP applications on the iSeries Apache web server. All our users are in IE. We use AD for our usernames within our network.

The current Apache server setup does not require users to enter our pages ... if you are on our network, you have access to the page.

Is there a way (via LDAP or other methods) to get the username registered in Windows? The final last resort would be to redirect users to an ASP.NET site hosted on our Windows servers and pass the username back to the PHP application. But then again, this is a last resort.

Link here: Can you get the Windows username (AD) in PHP? has a lot of good suggestions, however the AUTH_USER IS variable is empty as indicated in link ... and I don’t think that the iSeries Apache server can implement built-in auth for Windows.

If someone can explain my options and (if possible) the difficulty of these options ... that would be okay. Please be as specific as possible, as I have no problems with the LDAP or server settings.

+4
source share
2 answers

You can get it from an ActiveX object and JavaScript, since you are using IE. To get this in PHP, maybe include it as a hidden field on the login page?

try { var activex = new ActiveXObject('WScript.Network'); document.write(activex.userName); } catch (ex) { document.write("unable to get user info"); } 

Make sure that you have added this site to the trusted zone of the browser and included scripts to run it.

+3
source

From my experience writing SSO processing for PHP applications, you can do this work using a combination of mod_auth_ntlm and Kerberos (check this link , this is very close to what I remember, although my original installation was ~ 5 years ago in a Gentoo box). If I remember correctly, you should find the username in the variable $_SERVER["REMOTE_USER"] in this setting.

0
source

Source: https://habr.com/ru/post/1380815/


All Articles