Windows Authentication to get Windows Login ID


I’ve been looking for a easy way to get the users windows ID on my intranet portal PHP application. I found a few things but nothing that promising.

I have a MSSQL database and PHP on a IIS server. AD windows environment.

Any ideas for me to look into? Anyone done this?

Thanks in advance!


Anyone have any direction?

I have googled and found a few things but nothing great. Forums search doesn’t turn up much either.

Hi keith5885,

A long shot … Active Directory is essentially ldap that is wrapped. You may look into reading Active Directory via an ldap tool. Then you may be able to use one of the PHP ldap classes to tap into the Active Directory ldap. I can tell you that expect this to be very hairy experience.


XP anyway puts the username in an environment variable USERNAME on the client workstation, maybe you can get the username from javascript in the browser.

Or if IIS is in windows authentication mode I think there is a server variable with the username that you can retrieve with asp, and probably is available to php too.

If it’s on the intranet, and you have access to the startup scripts of computers on the network, you could create a startup script to log them into the intranet upon login.

Though I’d like to point out that instant-login can have some nasty security consequences - it might just be easier to make them log in.

This entry from stackoverflow may help the integrated security model that Windows provides allows for the credential to be cached and passed on to the server.

As the original OP of this thread last posted in June, it is safe for this thread to be closed.