Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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