Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Kristina Petravičiūtė
Kristina Petravičiūtė
11,270 Points

Get windows username using php

Hello,

I am trying to create intranet for my company as the new web developer. The intranet will be PHP - MSSQL driven. Does anyone know how I can get the username they used to log on to windows (Network) in my PHP scripts on the intranet.?

Thank you!

Gergő Bogdán
Gergő Bogdán
6,664 Points

Since PHP is interpreted and executed in some container, like Apache or NGinx on a server the way it should work is to authenticate users when these are trying to access the webpage implemented in PHP. For this you can use Single Sign On with Active directory if you have a windows network. If you could explain more details about what do you want to achieve we could give more concrete guidelines.

Kristina Petravičiūtė
Kristina Petravičiūtė
11,270 Points

Yes, I have windows network. So how can I use SSO with Active directory? I need to recognize user name and password in webpage based on php from windows log in information and automatically sing in into webpage. I don't know if you understand what I mean, but it's difficult for me to explain in English :)

Gergő Bogdán
Gergő Bogdán
6,664 Points

I am not a PHP expert so I cannot give you specific details, you'd have to look for concrete steps how to implement it. This link and this one gives a nice guide what is needed to use SSO with Apache/PHP.

1 Answer